Converts a pre C function to a Lua function and pushes it to the stack.
Pre C functions collect parameters from the stack and return a CInt
that represents number of return values left on the stack.
See CFunction for more info.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulehslua-core-2.3.2Haskell2010
Expose Haskell functions as Lua closures.
Converts a pre C function to a Lua function and pushes it to the stack.
Pre C functions collect parameters from the stack and return a CInt
that represents number of return values left on the stack.
See CFunction for more info.
Pushes Haskell function as a callable userdata. All values created will be garbage collected. The function should behave similar to a CFunction.
Error conditions should be indicated by raising a catchable exception
or by returning the result of .Lua.error
Example:
mod23 :: Lua NumResults
mod23 = do
mn <- tointeger (nthBottom 1)
case mn of
Nothing -> pushstring "expected an integer" *> error
Just n -> pushinteger (n `mod` 23)
pushHaskellFunction mod23
setglobal "mod23"