hslua-marshalling-2.1.0: Marshalling of values between Haskell and Lua.

Copyright | © 2020-2022 Albert Krewinkel
License | MIT
Maintainer | Albert Krewinkel <tarleb+hslua@zeitkraut.de>
Stability | beta
Portability | Portable
Safe Haskell | None
Language | Haskell2010

HsLua.Marshalling.Push

Contents

- Primitives
- Strings
- Collections
- Combinators

Description

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

Synopsis

- type Pusher e a = a -> LuaE e ()
- pushBool :: Pusher e Bool
- pushIntegral :: (Integral a, Show a) => a -> LuaE e ()
- pushRealFloat :: RealFloat a => a -> LuaE e ()
- pushByteString :: Pusher e ByteString
- pushLazyByteString :: Pusher e ByteString
- pushString :: String -> LuaE e ()
- pushText :: Pusher e Text
- pushName :: Name -> LuaE e ()
- pushList :: LuaError e => Pusher e a -> [a] -> LuaE e ()
- pushKeyValuePairs :: LuaError e => Pusher e a -> Pusher e b -> Pusher e [(a, b)]
- pushMap :: LuaError e => Pusher e a -> Pusher e b -> Pusher e (Map a b)
- pushSet :: LuaError e => Pusher e a -> Pusher e (Set a)
- pushPair :: LuaError e => Pusher e a -> Pusher e b -> (a, b) -> LuaE e ()
- pushTriple :: LuaError e => Pusher e a -> Pusher e b -> Pusher e c -> (a, b, c) -> LuaE e ()
- pushAsTable :: LuaError e => [(Name, a -> LuaE e ())] -> a -> LuaE e ()

# Documentation

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

Function to push a value to Lua's stack.

# Primitives

pushBool :: Pusher e Bool #

Pushes a `Bool` as a Lua boolean.

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

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

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 #

Pushes a `ByteString` as a raw string.

pushLazyByteString :: Pusher e ByteString #

Pushes a lazy `ByteString` as a raw string.

pushString :: String -> LuaE e () #

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

pushText :: Pusher e Text #

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

pushName :: Name -> LuaE e () #

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

# Collections

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

Push list as numerically indexed table.

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

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

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

Push `Map` as default key-value Lua table.

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

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

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

Pushes a value triple as a three element list.

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

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