| Copyright | © 2007–2012 Gracjan Polak 2012–2016 Ömer Sinan Ağacan 2017-2021 Albert Krewinkel | 
|---|---|
| License | MIT | 
| Maintainer | Albert Krewinkel <tarleb+hslua@zeitkraut.de> | 
| Stability | beta | 
| Portability | FlexibleInstances, ForeignFunctionInterface, ScopedTypeVariables | 
| Safe Haskell | None | 
| Language | Haskell2010 | 
HsLua.Class.Exposable
Description
Call Haskell functions from Lua.
Synopsis
- class PeekError e => Exposable e a where- partialApply :: StackIndex -> a -> LuaE e NumResults
 
- toHaskellFunction :: forall e a. Exposable e a => a -> HaskellFunction e
- registerHaskellFunction :: Exposable e a => Name -> a -> LuaE e ()
Documentation
class PeekError e => Exposable e a where Source #
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
Methods
partialApply :: StackIndex -> a -> LuaE e NumResults Source #
Helper function, called by toHaskellFunction
Instances
| PeekError e => Exposable e (HaskellFunction e) Source # | |
| Defined in HsLua.Class.Exposable Methods partialApply :: StackIndex -> HaskellFunction e -> LuaE e NumResults Source # | |
| (Peekable a, Exposable e b) => Exposable e (a -> b) Source # | |
| Defined in HsLua.Class.Exposable Methods partialApply :: StackIndex -> (a -> b) -> LuaE e NumResults Source # | |
| (PeekError e, Pushable a) => Exposable e (LuaE e a) Source # | |
| Defined in HsLua.Class.Exposable Methods partialApply :: StackIndex -> LuaE e a -> LuaE e NumResults Source # | |
toHaskellFunction :: forall e a. Exposable e a => a -> HaskellFunction e Source #
Convert a Haskell function to a function type directly exposable to Lua. Any Haskell function can be converted provided that:
Any Exception
Important: this does not catch exceptions other than
 Exception
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)))