Copyright | © 2020 Albert Krewinkel |
---|---|
License | MIT |
Maintainer | Albert Krewinkel <tarleb+hslua@zeitkraut.de> |
Stability | beta |
Portability | Portable |
Safe Haskell | None |
Language | Haskell2010 |
Functions which unmarshal and retrieve Haskell values from Lua's stack.
Synopsis
- type Peeker a = StackIndex -> Lua (Either PeekError a)
- newtype PeekError = PeekError {}
- errorMsg :: Text -> PeekError
- force :: Either PeekError a -> Lua a
- formatPeekError :: PeekError -> String
- pushMsg :: Text -> PeekError -> PeekError
- toPeeker :: (StackIndex -> Lua a) -> Peeker a
- peekBool :: Peeker Bool
- peekIntegral :: (Integral a, Read a) => Peeker a
- peekRealFloat :: (RealFloat a, Read a) => Peeker a
- peekByteString :: Peeker ByteString
- peekLazyByteString :: Peeker ByteString
- peekString :: Peeker String
- peekText :: Peeker Text
- peekKeyValuePairs :: Peeker a -> Peeker b -> Peeker [(a, b)]
- peekList :: Peeker a -> Peeker [a]
- peekMap :: Ord a => Peeker a -> Peeker b -> Peeker (Map a b)
- peekSet :: Ord a => Peeker a -> Peeker (Set a)
- optional :: Peeker a -> Peeker (Maybe a)
Documentation
type Peeker a = StackIndex -> Lua (Either PeekError a) Source #
Function to retrieve a value from Lua's stack.
List of errors which occurred while retrieving a value from the stack.
force :: Either PeekError a -> Lua a Source #
Force creation of a result, throwing an exception if that's not possible.
formatPeekError :: PeekError -> String Source #
Primitives
peekIntegral :: (Integral a, Read a) => Peeker a Source #
Retrieves an Integral
value from the Lua 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.
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.