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

Modulehslua-marshalling-2.3.2Haskell2010

HsLua.Marshalling.Peekers

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

Contents
  1. Peeking values from the stack
  2. Primitives
  3. Strings
  4. Readable types
  5. Collections
  6. Combinators
  7. Building peek functions
Synopsis

Peeking values from the stack

Primitives

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.

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.