HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulehslua-classes-2.3.1Haskell2010

HsLua.Classes

Convenience module which re-exports all classes and utility functions provided by the hslua-classes package.

  • 1 type
  • 3 classes
  • 7 values

Receiving values from Lua stack (Lua → Haskell)

2 declarations
classclass Peekable a where
#

A value that can be read from the Lua stack.

Methods

Instances26Peekable, …

Pushing values to Lua stack (Haskell → Lua)

2 declarations
classclass Pushable a where
#

A value that can be pushed to the Lua stack.

Methods

  • push :: LuaError e => a -> LuaE e ()

    Pushes a value onto Lua stack, casting it into meaningfully nearest Lua type.

Instances25Pushable, …

Calling Functions

4 declarations
classclass LuaError e => Exposable e a where
#

Operations and functions that can be pushed to the Lua stack. This is a helper function not intended to be used directly. Use the toHaskellFunction wrapper instead.

Methods

  • partialApply :: StackIndex -> a -> Peek e NumResults

    Helper function, called by toHaskellFunction. Should do a partial application of the argument at the given index to the underlying function. Recurses if necessary, causing further partial applications until the operation is a easily exposable to Lua.

Instances4Exposable
valuetoHaskellFunction :: Exposable e a => a -> HaskellFunction e
#

Convert a Haskell function to a function type directly exposable to Lua. Any Haskell function can be converted provided that:

  • all arguments are instances of Peekable

  • return type is LuaE e a, where a is an instance of Pushable

Any exception of type e will be caught.

Important: this does not catch exceptions other than e; exception handling must be done by the Haskell function. Failure to do so will cause the program to crash.

E.g., the following code could be used to handle an Exception of type FooException, if that type is an instance of MonadCatch and Pushable:

toHaskellFunction (myFun `catchM` (\e -> raiseError (e :: FooException)))
valueinvoke :: Invokable a => Name -> a
#

Invoke a Lua function. Use as:

v <- invoke "proc" "abc" (1::Int) (5.0::Double)

Utility functions and types

2 declarations
newtypenewtype 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

Instances2Peekable, Pushable

Retrieving values

valuepopValue :: (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.