HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Receiving values from Lua stack (Lua → Haskell)

datadata Result a

Record to keep track of failure contexts while retrieving objects from the Lua stack.

Constructors

Instances10Monad, Functor, MonadFail, Applicative, Foldable, Traversable, …
  • Monad ResultDefined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • Functor ResultDefined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • MonadFail ResultDefined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • Applicative ResultDefined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • Foldable ResultDefined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • Traversable ResultDefined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • Alternative ResultDefined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • MonadPlus ResultDefined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • Eq a => Eq (Result a)Defined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • Show a => Show (Result a)Defined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek

Primitive types

Strings

Readable types

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.

Lua peek monad

newtypenewtype Peek e a

Lua operation with an additional failure mode that can stack errors from different contexts; errors are not based on exceptions).

Constructors

Instances6Monad, Functor, MonadFail, Applicative, Alternative, MonadPlus
  • Monad (Peek e)Defined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • Functor (Peek e)Defined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • MonadFail (Peek e)Defined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • Applicative (Peek e)Defined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • Alternative (Peek e)Defined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
  • MonadPlus (Peek e)Defined in hslua-marshalling-2.3.2 · HsLua.Marshalling.Peek
valuelastly :: Peek e a -> LuaE e b -> Peek e a

Runs the peek action and Lua action in sequence, even if the peek action fails.

valuecleanup :: Peek e a -> Peek e a

Runs the peek action, resetting the stack top afterwards. This can be used with peek actions that might otherwise leave elements on the stack in case of a failure.

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.

Pushing values to Lua stack (Haskell → Lua)

Utilities

valuepushIterator
  1. :: LuaError e
  2. => (a -> LuaE e NumResults)

    pusher for the values

  3. -> [a]

    list to iterate over lazily

  4. -> LuaE e NumResults

Pushes three values to the stack that can be used in a generic for loop to lazily iterate over all values in the list. Keeps the remaining list in a userdata state.

If the values pusher function returns NumResults 0 for a list item, then this item will be skipped and the values for the next item will be pushed.