hslua-marshalling-2.1.0: Marshalling of values between Haskell and Lua.
Copyright© 2020-2022 Albert Krewinkel
LicenseMIT
MaintainerAlbert Krewinkel <tarleb+hslua@zeitkraut.de>
Stabilitybeta
PortabilityPortable
Safe HaskellNone
LanguageHaskell2010

HsLua.Marshalling.Push

Description

Functions which marshal and push Haskell values onto Lua's stack.

Synopsis

Documentation

type Pusher e a = a -> LuaE e () Source #

Function to push a value to Lua's stack.

Primitives

pushBool :: Pusher e Bool Source #

Pushes a Bool as a Lua boolean.

pushIntegral :: (Integral a, Show a) => a -> LuaE e () Source #

Pushes an Integer to the Lua stack. Values representable as Lua integers are pushed as such; bigger integers are represented using their string representation.

pushRealFloat :: RealFloat a => a -> LuaE e () Source #

Push a floating point number to the Lua stack. Uses a string representation for all types which do not match the float properties of the Number type.

Strings

pushByteString :: Pusher e ByteString Source #

Pushes a ByteString as a raw string.

pushLazyByteString :: Pusher e ByteString Source #

Pushes a lazy ByteString as a raw string.

pushString :: String -> LuaE e () Source #

Pushes a String as a UTF-8 encoded Lua string.

pushText :: Pusher e Text Source #

Pushes a Text value as a UTF-8 encoded string.

pushName :: Name -> LuaE e () Source #

Pushes a Name as a UTF-8 encoded Lua string.

Collections

pushList :: LuaError e => Pusher e a -> [a] -> LuaE e () Source #

Push list as numerically indexed table.

pushKeyValuePairs :: LuaError e => Pusher e a -> Pusher e b -> Pusher e [(a, b)] Source #

Push list of pairs as default key-value Lua table.

pushMap :: LuaError e => Pusher e a -> Pusher e b -> Pusher e (Map a b) Source #

Push Map as default key-value Lua table.

pushSet :: LuaError e => Pusher e a -> Pusher e (Set a) Source #

Push a Set as idiomatic Lua set, i.e., as a table with the set elements as keys and true as values.

Combinators

pushPair :: LuaError e => Pusher e a -> Pusher e b -> (a, b) -> LuaE e () Source #

Pushes a pair of values as a two element list.

pushTriple :: LuaError e => Pusher e a -> Pusher e b -> Pusher e c -> (a, b, c) -> LuaE e () Source #

Pushes a value triple as a three element list.

pushAsTable :: LuaError e => [(Name, a -> LuaE e ())] -> a -> LuaE e () Source #

Pushes an object as a table, defined by a list of field-names/push-function pairs.