hslua-1.1.1: 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) #

Function to retrieve a value from Lua's stack.

newtype PeekError #

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

Constructors

PeekError 
Instances
Eq PeekError # 
Instance details

Defined in Foreign.Lua.Peek

Show PeekError # 
Instance details

Defined in Foreign.Lua.Peek

errorMsg :: Text -> PeekError #

Create a peek error from an error message.

force :: Either PeekError a -> Lua a #

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

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

Convert an old peek funtion to a Peeker.

Primitives

peekBool :: Peeker Bool #

Retrieves a Bool as a Lua boolean.

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

Retrieves an Integral value from the Lua stack.

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

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

Strings

peekByteString :: Peeker ByteString #

Retrieves a ByteString as a raw string.

peekLazyByteString :: Peeker ByteString #

Retrieves a lazy ByteString as a raw string.

peekString :: Peeker String #

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

peekText :: Peeker Text #

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

Collections

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

Read a table into a list of pairs.

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

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) #

Retrieves a key-value Lua table as Map.

peekSet :: Ord a => Peeker a -> Peeker (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.