hslua-classes-2.3.1: Type classes for HsLua

Copyright | © 2007–2012 Gracjan Polak; © 2012–2016 Ömer Sinan Ağacan; © 2017-2024 Albert Krewinkel
License | MIT
Maintainer | Albert Krewinkel <tarleb@hslua.org>
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 Source #

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

newtype Optional a Source #

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) Source # |
Instance details Defined in HsLua.Class.Util Methods safepeek :: LuaError e => Peeker e (Optional a) Source #
Pushable a => Pushable (Optional a) Source # |
Instance details Defined in HsLua.Class.Util Methods push :: LuaError e => Optional a -> LuaE e () Source #

# getting values

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

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 Source #

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