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 |
Instances
Monad Result Source # | |
Functor Result Source # | |
Applicative Result Source # | |
Foldable Result Source # | |
Defined in HsLua.Marshalling.Peek fold :: Monoid m => Result m -> m # foldMap :: Monoid m => (a -> m) -> Result a -> m # foldMap' :: Monoid m => (a -> m) -> Result a -> m # foldr :: (a -> b -> b) -> b -> Result a -> b # foldr' :: (a -> b -> b) -> b -> Result a -> b # foldl :: (b -> a -> b) -> b -> Result a -> b # foldl' :: (b -> a -> b) -> b -> Result a -> b # foldr1 :: (a -> a -> a) -> Result a -> a # foldl1 :: (a -> a -> a) -> Result a -> a # elem :: Eq a => a -> Result a -> Bool # maximum :: Ord a => Result a -> a # minimum :: Ord a => Result a -> a # | |
Traversable Result Source # | |
Alternative Result Source # | |
MonadPlus Result Source # | |
Eq a => Eq (Result a) Source # | |
Show a => Show (Result a) Source # | |
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.