hslua-classes-2.1.0: Type classes for HsLua

Copyright | © 2007–2012 Gracjan Polak; © 2012–2016 Ömer Sinan Ağacan; © 2017-2022 Albert Krewinkel
License | MIT
Maintainer | Albert Krewinkel <tarleb+hslua@zeitkraut.de>
Stability | beta
Portability | non-portable (depends on GHC)
Safe Haskell | None
Language | Haskell2010

HsLua.Class.Util

Contents

- getting values

Description

HsLua utility functions.

Synopsis

- raiseError :: (LuaError e, Pushable a) => a -> LuaE e NumResults
- newtype Optional a = Optional {
  - fromOptional :: Maybe a
  }
- peekEither :: (LuaError e, Peekable a) => StackIndex -> LuaE e (Either e a)
- popValue :: (LuaError e, Peekable a) => LuaE e a

# Documentation

raiseError :: (LuaError e, Pushable a) => a -> LuaE e NumResults #

Raise a Lua error, using the given value as the error object.

newtype Optional a #

Newtype wrapper intended to be used for optional Lua values. Nesting this type is strongly discouraged as missing values on inner levels are indistinguishable from missing values on an outer level; wrong values would be the likely result.

Constructors

Optional |
Fields fromOptional :: Maybe a

#### Instances

Instances details

Peekable a => Peekable (Optional a) # |
Instance details Defined in HsLua.Class.Util Methods safepeek :: LuaError e => Peeker e (Optional a) #
Pushable a => Pushable (Optional a) # |
Instance details Defined in HsLua.Class.Util Methods push :: LuaError e => Optional a -> LuaE e () #

# getting values

peekEither :: (LuaError e, Peekable a) => StackIndex -> LuaE e (Either e a) #

Try to convert the value at the given stack index to a Haskell value. Returns `Left` with the error on failure.

popValue :: (LuaError e, Peekable a) => LuaE e a #

Get, then pop the value at the top of the stack. The pop operation is executed even if the retrieval operation failed.