-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Bindings to Lua, an embeddable scripting language
--   
--   HsLua provides wrappers and helpers to bridge Haskell and <a>Lua</a>.
--   
--   It builds upon the <i>lua</i> package, which allows to bundle a Lua
--   interpreter with a Haskell program.
--   
--   Example programs can be found in the <tt>hslua-examples</tt> subdir of
--   the project <a>repository</a>.
@package hslua
@version 2.5.0


-- | HsLua utility functions.
module HsLua.Util

-- | Like <tt>getglobal</tt>, but knows about packages and nested tables.
--   E.g.
--   
--   <pre>
--   getglobal' "math.sin"
--   </pre>
--   
--   will return the function <tt>sin</tt> in package <tt>math</tt>.
getglobal' :: LuaError e => Name -> LuaE e ()

-- | Like <tt>setglobal</tt>, but knows about packages and nested tables.
--   E.g.
--   
--   <pre>
--   pushstring "0.9.4"
--   setglobal' "mypackage.version"
--   </pre>
--   
--   All tables and fields, except for the last field, must exist.
setglobal' :: LuaError e => Name -> LuaE e ()


-- | Functions and utilities enabling the seamless integration of a Lua
--   interpreter into a Haskell project.
--   
--   This module combines and re-exports the functionality of the HsLua
--   framework. Basic access to the Lua API is provided by
--   <tt><a>Core</a></tt> from Hackage package <i>lua</i>.
module HsLua
type Lua a = LuaE Exception a
newtype LuaE e a
Lua :: ReaderT LuaEnvironment IO a -> LuaE e a
[unLua] :: LuaE e a -> ReaderT LuaEnvironment IO a
data RelationalOperator
EQ :: RelationalOperator
LT :: RelationalOperator
LE :: RelationalOperator
newtype Integer
Integer :: Int64 -> Integer
data Type
TypeNone :: Type
TypeNil :: Type
TypeBoolean :: Type
TypeLightUserdata :: Type
TypeNumber :: Type
TypeString :: Type
TypeTable :: Type
TypeFunction :: Type
TypeUserdata :: Type
TypeThread :: Type
concat :: LuaError e => NumArgs -> LuaE e ()
compare :: LuaError e => StackIndex -> StackIndex -> RelationalOperator -> LuaE e Bool
error :: LuaE e NumResults
rotate :: StackIndex -> Int -> LuaE e ()
newtype Number
Number :: Double -> Number
newtype Exception
Exception :: String -> Exception
[exceptionMessage] :: Exception -> String
insert :: StackIndex -> LuaE e ()

-- | Lift a computation from the <a>IO</a> monad. This allows us to run IO
--   computations in any monadic stack, so long as it supports these kinds
--   of operations (i.e. <a>IO</a> is the base monad for the stack).
--   
--   <h3><b>Example</b></h3>
--   
--   <pre>
--   import Control.Monad.Trans.State -- from the "transformers" library
--   
--   printState :: Show s =&gt; StateT s IO ()
--   printState = do
--     state &lt;- get
--     liftIO $ print state
--   </pre>
--   
--   Had we omitted <tt><a>liftIO</a></tt>, we would have ended up with
--   this error:
--   
--   <pre>
--   • Couldn't match type ‘IO’ with ‘StateT s IO’
--    Expected type: StateT s IO ()
--      Actual type: IO ()
--   </pre>
--   
--   The important part here is the mismatch between <tt>StateT s IO
--   ()</tt> and <tt><a>IO</a> ()</tt>.
--   
--   Luckily, we know of a function that takes an <tt><a>IO</a> a</tt> and
--   returns an <tt>(m a)</tt>: <tt><a>liftIO</a></tt>, enabling us to run
--   the program and see the expected results:
--   
--   <pre>
--   &gt; evalStateT printState "hello"
--   "hello"
--   
--   &gt; evalStateT printState 3
--   3
--   </pre>
liftIO :: MonadIO m => IO a -> m a
close :: State -> IO ()
gc :: GCControl -> LuaE e Int
try :: Exception e => LuaE e a -> LuaE e (Either e a)
copy :: StackIndex -> StackIndex -> LuaE e ()
newtype State
State :: Ptr () -> State
pcall :: NumArgs -> NumResults -> Maybe StackIndex -> LuaE e Status
next :: LuaError e => StackIndex -> LuaE e Bool
type CFunction = FunPtr PreCFunction
data Status
OK :: Status
Yield :: Status
ErrRun :: Status
ErrSyntax :: Status
ErrMem :: Status
ErrErr :: Status
ErrFile :: Status
load :: Reader -> Ptr () -> Name -> LuaE e Status
refnil :: Int
noref :: Int
newtype NumResults
NumResults :: CInt -> NumResults
[fromNumResults] :: NumResults -> CInt
newtype NumArgs
NumArgs :: CInt -> NumArgs
[fromNumArgs] :: NumArgs -> CInt
newtype StackIndex
StackIndex :: CInt -> StackIndex
[fromStackIndex] :: StackIndex -> CInt
type PreCFunction = State -> IO NumResults
data Reference
Reference :: CInt -> Reference
RefNil :: Reference
fromReference :: Reference -> CInt
toReference :: CInt -> Reference
nthTop :: CInt -> StackIndex
nthBottom :: CInt -> StackIndex
nth :: CInt -> StackIndex
top :: StackIndex
newtype Name
Name :: ByteString -> Name
[fromName] :: Name -> ByteString
data GCControl
GCStop :: GCControl
GCRestart :: GCControl
GCCollect :: GCControl
GCCount :: GCControl
GCCountb :: GCControl
GCStep :: CInt -> GCControl
GCInc :: CInt -> CInt -> CInt -> GCControl
GCGen :: CInt -> CInt -> GCControl
GCIsRunning :: GCControl
type HaskellFunction e = LuaE e NumResults
newtype LuaEnvironment
LuaEnvironment :: State -> LuaEnvironment
[luaEnvState] :: LuaEnvironment -> State
state :: LuaE e State
runWith :: State -> LuaE e a -> IO a
unsafeRunWith :: State -> LuaE e a -> IO a
multret :: NumResults
registryindex :: StackIndex
newhsuserdatauv :: a -> Int -> LuaE e ()
newudmetatable :: Name -> LuaE e Bool
fromuserdata :: forall a e. StackIndex -> Name -> LuaE e (Maybe a)
putuserdata :: StackIndex -> Name -> a -> LuaE e Bool
getupvalue :: StackIndex -> Int -> LuaE e (Maybe Name)
setupvalue :: StackIndex -> Int -> LuaE e (Maybe Name)
class Exception e => LuaError e
popException :: LuaError e => LuaE e e
pushException :: LuaError e => e -> LuaE e ()
luaException :: LuaError e => String -> e
failLua :: LuaError e => String -> LuaE e a
throwErrorAsException :: LuaError e => LuaE e a
throwTypeMismatchError :: LuaError e => ByteString -> StackIndex -> LuaE e a
changeErrorType :: forall old new a. LuaE old a -> LuaE new a
popErrorMessage :: State -> IO ByteString
pushTypeMismatchError :: ByteString -> StackIndex -> LuaE e ()
absindex :: StackIndex -> LuaE e StackIndex
call :: LuaError e => NumArgs -> NumResults -> LuaE e ()
checkstack :: Int -> LuaE e Bool
createtable :: Int -> Int -> LuaE e ()
equal :: LuaError e => StackIndex -> StackIndex -> LuaE e Bool
getfield :: LuaError e => StackIndex -> Name -> LuaE e Type
getglobal :: LuaError e => Name -> LuaE e Type
getmetatable :: StackIndex -> LuaE e Bool
gettable :: LuaError e => StackIndex -> LuaE e Type
gettop :: LuaE e StackIndex
getiuservalue :: StackIndex -> Int -> LuaE e Type
isboolean :: StackIndex -> LuaE e Bool
iscfunction :: StackIndex -> LuaE e Bool
isfunction :: StackIndex -> LuaE e Bool
isinteger :: StackIndex -> LuaE e Bool
islightuserdata :: StackIndex -> LuaE e Bool
isnil :: StackIndex -> LuaE e Bool
isnone :: StackIndex -> LuaE e Bool
isnoneornil :: StackIndex -> LuaE e Bool
isnumber :: StackIndex -> LuaE e Bool
isstring :: StackIndex -> LuaE e Bool
istable :: StackIndex -> LuaE e Bool
isthread :: StackIndex -> LuaE e Bool
isuserdata :: StackIndex -> LuaE e Bool
lessthan :: LuaError e => StackIndex -> StackIndex -> LuaE e Bool
ltype :: StackIndex -> LuaE e Type
newtable :: LuaE e ()
newuserdatauv :: Int -> Int -> LuaE e (Ptr ())
openlibs :: LuaE e ()
openbase :: LuaError e => LuaE e ()
opendebug :: LuaError e => LuaE e ()
openio :: LuaError e => LuaE e ()
openmath :: LuaError e => LuaE e ()
openos :: LuaError e => LuaE e ()
openpackage :: LuaError e => LuaE e ()
openstring :: LuaError e => LuaE e ()
opentable :: LuaError e => LuaE e ()
pop :: Int -> LuaE e ()
pushboolean :: Bool -> LuaE e ()
pushcclosure :: CFunction -> NumArgs -> LuaE e ()
pushcfunction :: CFunction -> LuaE e ()
pushglobaltable :: LuaE e ()
pushinteger :: Integer -> LuaE e ()
pushlightuserdata :: Ptr a -> LuaE e ()
pushnil :: LuaE e ()
pushnumber :: Number -> LuaE e ()
pushstring :: ByteString -> LuaE e ()
pushthread :: LuaE e Bool
pushvalue :: StackIndex -> LuaE e ()
rawequal :: StackIndex -> StackIndex -> LuaE e Bool
rawget :: LuaError e => StackIndex -> LuaE e Type
rawgeti :: LuaError e => StackIndex -> Integer -> LuaE e Type
rawlen :: StackIndex -> LuaE e Int
rawset :: LuaError e => StackIndex -> LuaE e ()
rawseti :: LuaError e => StackIndex -> Integer -> LuaE e ()
register :: LuaError e => Name -> CFunction -> LuaE e ()
remove :: StackIndex -> LuaE e ()
replace :: StackIndex -> LuaE e ()
setfield :: LuaError e => StackIndex -> Name -> LuaE e ()
setglobal :: LuaError e => Name -> LuaE e ()
setmetatable :: StackIndex -> LuaE e ()
settable :: LuaError e => StackIndex -> LuaE e ()
settop :: StackIndex -> LuaE e ()
setiuservalue :: StackIndex -> Int -> LuaE e Bool
setwarnf :: WarnFunction -> Ptr () -> LuaE e ()
status :: LuaE e Status
toboolean :: StackIndex -> LuaE e Bool
tocfunction :: StackIndex -> LuaE e (Maybe CFunction)
tointeger :: StackIndex -> LuaE e (Maybe Integer)
tonumber :: StackIndex -> LuaE e (Maybe Number)
topointer :: StackIndex -> LuaE e (Ptr ())
tostring :: StackIndex -> LuaE e (Maybe ByteString)
tothread :: StackIndex -> LuaE e (Maybe State)
touserdata :: StackIndex -> LuaE e (Maybe (Ptr a))
typename :: Type -> LuaE e ByteString
upvalueindex :: StackIndex -> StackIndex
pushPreCFunction :: PreCFunction -> LuaE e ()
pushHaskellFunction :: LuaError e => HaskellFunction e -> LuaE e ()
checkstack' :: LuaError e => Int -> String -> LuaE e ()
dostring :: ByteString -> LuaE e Status
dofile :: Maybe FilePath -> LuaE e Status
getmetafield :: StackIndex -> Name -> LuaE e Type
getmetatable' :: Name -> LuaE e Type
getref :: LuaError e => StackIndex -> Reference -> LuaE e Type
getsubtable :: LuaError e => StackIndex -> Name -> LuaE e Bool
loadbuffer :: ByteString -> Name -> LuaE e Status
loadfile :: Maybe FilePath -> LuaE e Status
loadstring :: ByteString -> LuaE e Status
newmetatable :: Name -> LuaE e Bool
newstate :: IO State
ref :: StackIndex -> LuaE e Reference
requiref :: LuaError e => Name -> CFunction -> Bool -> LuaE e ()
tostring' :: LuaError e => StackIndex -> LuaE e ByteString
traceback :: State -> Maybe ByteString -> Int -> LuaE e ()
unref :: StackIndex -> Reference -> LuaE e ()
where' :: Int -> LuaE e ()
loaded :: Name
preload :: Name
data GCManagedState
run :: LuaE e a -> IO a
runEither :: Exception e => LuaE e a -> IO (Either e a)
newGCManagedState :: IO GCManagedState
closeGCManagedState :: GCManagedState -> IO ()
withGCManagedState :: GCManagedState -> LuaE e a -> IO a
pcallTrace :: NumArgs -> NumResults -> LuaE e Status
callTrace :: LuaError e => NumArgs -> NumResults -> LuaE e ()
dofileTrace :: Maybe FilePath -> LuaE e Status
dostringTrace :: ByteString -> LuaE e Status
requirehs :: LuaError e => Name -> (Name -> LuaE e ()) -> LuaE e ()
preloadhs :: LuaError e => Name -> LuaE e NumResults -> LuaE e ()
setwarnf' :: LuaError e => (ByteString -> LuaE e ()) -> LuaE e ()

-- | A value that can be pushed to the Lua stack.
class Pushable a

-- | Pushes a value onto Lua stack, casting it into meaningfully nearest
--   Lua type.
push :: (Pushable a, LuaError e) => a -> LuaE e ()
pushValue :: LuaError e => Pusher e Value
jsonarray :: Name
peekValue :: LuaError e => Peeker e Value
pushToAeson :: Pusher e (ToAeson e)
peekToAeson :: Peeker e (ToAeson e)
peekViaJSON :: (FromJSON a, LuaError e) => Peeker e a
pushViaJSON :: (ToJSON a, LuaError e) => Pusher e a

-- | Like <tt>getglobal</tt>, but knows about packages and nested tables.
--   E.g.
--   
--   <pre>
--   getglobal' "math.sin"
--   </pre>
--   
--   will return the function <tt>sin</tt> in package <tt>math</tt>.
getglobal' :: LuaError e => Name -> LuaE e ()

-- | Like <tt>setglobal</tt>, but knows about packages and nested tables.
--   E.g.
--   
--   <pre>
--   pushstring "0.9.4"
--   setglobal' "mypackage.version"
--   </pre>
--   
--   All tables and fields, except for the last field, must exist.
setglobal' :: LuaError e => Name -> LuaE e ()
