HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulehslua-marshalling-2.3.1Haskell2010

HsLua.Marshalling.Peekers

Functions which unmarshal and retrieve Haskell values from Lua's stack.

  • 28 values

Peeking values from the stack

0 declarations

Primitives

valuepeekNil :: Peeker e ()
#

Succeeds if the value at the given index is nil.

valuepeekNoneOrNil :: Peeker e ()
#

Succeeds if the given index is not valid or if the value at this index is nil.

Strings

valuepeekStringy :: IsString a => Peeker e a
#

Retrieves a String-like value from an UTF-8 encoded Lua string.

This should not be used to peek ByteString values or other values for which construction via fromString can result in loss of information.

Readable types

valuepeekRead :: Read a => Peeker e a
#

Retrieves a value by getting a String from Lua, then using readMaybe to convert the String into a Haskell value.

Collections

valuepeekList :: LuaError e => Peeker e a -> Peeker e [a]
#

Reads a numerically indexed table t into a list, where the length of the list is equal to rawlen(t). The operation will fail unless all numerical fields between 1 and rawlen(t) can be retrieved.

valuepeekSet :: (LuaError e, Ord a) => Peeker e a -> Peeker e (Set a)
#

Retrieves a Set from an idiomatic Lua representation. A set in Lua is idiomatically represented as a table with the elements as keys. Elements with falsy values are omitted.

Combinators

valuepeekPair :: LuaError e => Peeker e a -> Peeker e b -> Peeker e (a, b)
#

Retrieves a value pair from a table. Expects the values to be stored in a numerically indexed table; does not access metamethods.

valuepeekTriple
  1. :: LuaError e
  2. => Peeker e a
  3. -> Peeker e b
  4. -> Peeker e c
  5. -> Peeker e (a, b, c)
#

Retrieves a value triple from a table. Expects the values to be stored in a numerically indexed table, with no metamethods.

Building peek functions

valuetypeChecked
  1. :: Name

    expected type

  2. -> (StackIndex -> LuaE e Bool)

    pre-condition checker

  3. -> Peeker e a
  4. -> Peeker e a
#

Use test to check whether the value at stack index n has the correct type and use peekfn to convert it to a Haskell value if possible. A successfully received value is wrapped using the Right constructor, while a type mismatch results in Left PeekError with the given error message.