hslua-1.1.2: Bindings to Lua, an embeddable scripting language

Copyright© 2020 Albert Krewinkel
LicenseMIT
MaintainerAlbert Krewinkel <tarleb+hslua@zeitkraut.de>
Stabilitybeta
PortabilityPortable
Safe HaskellNone
LanguageHaskell2010

Foreign.Lua.Peek

Contents

Description

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

Synopsis

Documentation

type Peeker a = StackIndex -> Lua (Either PeekError a) Source #

Function to retrieve a value from Lua's stack.

newtype PeekError Source #

List of errors which occurred while retrieving a value from the stack.

Constructors

PeekError 
Instances
Eq PeekError Source # 
Instance details

Defined in Foreign.Lua.Peek

Show PeekError Source # 
Instance details

Defined in Foreign.Lua.Peek

errorMsg :: Text -> PeekError Source #

Create a peek error from an error message.

force :: Either PeekError a -> Lua a Source #

Force creation of a result, throwing an exception if that's not possible.

toPeeker :: (StackIndex -> Lua a) -> Peeker a Source #

Convert an old peek funtion to a Peeker.

Primitives

peekBool :: Peeker Bool Source #

Retrieves a Bool as a Lua boolean.

peekIntegral :: (Integral a, Read a) => Peeker a Source #

Retrieves an Integral value from the Lua stack.

peekRealFloat :: (RealFloat a, Read a) => Peeker a Source #

Retrieve a RealFloat (e.g., Float or Double) from the stack.

Strings

peekByteString :: Peeker ByteString Source #

Retrieves a ByteString as a raw string.

peekLazyByteString :: Peeker ByteString Source #

Retrieves a lazy ByteString as a raw string.

peekString :: Peeker String Source #

Retrieves a String as an UTF-8 encoded Lua string.

peekText :: Peeker Text Source #

Retrieves a Text value as an UTF-8 encoded string.

Collections

peekKeyValuePairs :: Peeker a -> Peeker b -> Peeker [(a, b)] Source #

Read a table into a list of pairs.

peekList :: Peeker a -> Peeker [a] Source #

Reads a numerically indexed table t into a list, where the length of the list is equal to #t. The operation will fail if a numerical field n with 1 ≤ n < #t is missing.

peekMap :: Ord a => Peeker a -> Peeker b -> Peeker (Map a b) Source #

Retrieves a key-value Lua table as Map.

peekSet :: Ord a => Peeker a -> Peeker (Set a) Source #

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.