Copyright | © 2020-2022 Albert Krewinkel |
---|---|
License | MIT |
Maintainer | Albert Krewinkel <tarleb+hslua@zeitkraut.de> |
Stability | beta |
Portability | Portable |
Safe Haskell | None |
Language | Haskell2010 |
Types for unmarshalling of values from Lua.
Synopsis
- type Peeker e a = StackIndex -> Peek e a
- runPeeker :: Peeker e a -> StackIndex -> LuaE e (Result a)
- data Result a
- = Success !a
- | Failure ByteString [Name]
- isFailure :: Result a -> Bool
- failure :: ByteString -> Result a
- force :: LuaError e => Result a -> LuaE e a
- retrieving :: Name -> Peek e a -> Peek e a
- resultToEither :: Result a -> Either String a
- toPeeker :: LuaError e => (StackIndex -> LuaE e a) -> Peeker e a
- newtype Peek e a = Peek {}
- forcePeek :: LuaError e => Peek e a -> LuaE e a
- failPeek :: forall a e. ByteString -> Peek e a
- liftLua :: LuaE e a -> Peek e a
- withContext :: Name -> Peek e a -> Peek e a
- lastly :: Peek e a -> LuaE e b -> Peek e a
- cleanup :: Peek e a -> Peek e a
Documentation
type Peeker e a = StackIndex -> Peek e a Source #
Function to retrieve a value from Lua's stack.
Record to keep track of failure contexts while retrieving objects from the Lua stack.
Success !a | |
Failure ByteString [Name] | Error message and stack of contexts |
failure :: ByteString -> Result a Source #
Create a peek failure record from an error message.
force :: LuaError e => Result a -> LuaE e a Source #
Force creation of an unwrapped result, throwing an exception if that's not possible.
retrieving :: Name -> Peek e a -> Peek e a Source #
Add context information to the peek traceback stack.
resultToEither :: Result a -> Either String a Source #
Converts a Result into an Either, where Left
holds the reportable
string in case of an failure.
toPeeker :: LuaError e => (StackIndex -> LuaE e a) -> Peeker e a Source #
Converts an old peek funtion to a Peeker
.
Lua peek monad
Lua operation with an additional failure mode that can stack errors from different contexts; errors are not based on exceptions).
forcePeek :: LuaError e => Peek e a -> LuaE e a Source #
Converts a Peek action into a LuaE action, throwing an exception in case of a peek failure.
failPeek :: forall a e. ByteString -> Peek e a Source #
Fails the peek operation.