Succeeds if the value at the given index is nil.
Modulehslua-marshalling-2.3.1Haskell2010
HsLua.Marshalling.Peekers
Functions which unmarshal and retrieve Haskell values from Lua's stack.
- 28 values
- Packagehslua-marshalling-2.3.1
- Exports28
- LanguageHaskell2010
- LicenceMIT
- SourcePeekers.hs
Peeking values from the stack
0 declarationsPrimitives
Succeeds if the given index is not valid or if the value at this
index is nil.
Retrieves a Bool as a Lua boolean.
Retrieves an Integral value from the Lua stack.
Strings
Retrieves a ByteString as a raw string.
Retrieves a lazy ByteString as a raw string.
Retrieves a String from an UTF-8 encoded Lua string.
Retrieves a Text value as an UTF-8 encoded string.
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.
Retrieves a Lua string as Name.
Readable types
Retrieves a value by getting a String from Lua, then using readMaybe to convert the String into a Haskell value.
Collections
Read a table into a list of pairs.
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.
Like peekList, but fails if the list is empty.
Retrieves a key-value Lua table as Map.
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
Try all peekers and return the result of the first to succeed.
Get value at key from a table.
Get value at integer index key from a table.
Returns empty if the value at the given index is nil;
otherwise returns the result of peeker p.
Returns empty if the value at the given index is none;
otherwise returns the result of peeker p.
Returns empty if the value at the given index is none or
nil; otherwise returns the result of peeker p.
Retrieves a value pair from a table. Expects the values to be stored in a numerically indexed table; does not access metamethods.
Retrieves a value triple from a table. Expects the values to be stored in a numerically indexed table, with no metamethods.
Building peek functions
typeChecked 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.
Report the expected and actual type of the value under the given index if conversion failed.
typeMismatchMessage :: Nameexpected type
-> StackIndexindex of offending value
-> Peek e ByteString
Generate a type mismatch error.