hslua-core-2.3.2: Bindings to Lua, an embeddable scripting language

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.Core.Types

Contents

- References
- Stack index helpers
- Table field names

Description

The core Lua types, including mappings of Lua types to Haskell.

This module has mostly been moved to ``Types`` and currently re-exports that module. This module might be removed in the future.

Synopsis

- newtype LuaE e a = Lua {
  - unLua :: ReaderT LuaEnvironment IO a
  }
- newtype LuaEnvironment = LuaEnvironment {
  - luaEnvState :: State
  }
- newtype State = State (Ptr ())
- type Reader = FunPtr (State -> Ptr () -> Ptr CSize -> IO (Ptr CChar))
- liftLua :: (State -> IO a) -> LuaE e a
- liftLua1 :: (State -> a -> IO b) -> a -> LuaE e b
- state :: LuaE e State
- runWith :: State -> LuaE e a -> IO a
- unsafeRunWith :: State -> LuaE e a -> IO a
- data GCControl
  - = GCStop
  - | GCRestart
  - | GCCollect
  - | GCCount
  - | GCCountb
  - | GCStep CInt
  - | GCInc CInt CInt CInt
  - | GCGen CInt CInt
  - | GCIsRunning
- toGCcode :: GCControl -> GCCode
- toGCdata :: GCControl -> (CInt, CInt, CInt)
- data Type
  - = TypeNone
  - | TypeNil
  - | TypeBoolean
  - | TypeLightUserdata
  - | TypeNumber
  - | TypeString
  - | TypeTable
  - | TypeFunction
  - | TypeUserdata
  - | TypeThread
- fromType :: Type -> TypeCode
- toType :: TypeCode -> Type
- liftIO :: MonadIO m => IO a -> m a
- type CFunction = FunPtr PreCFunction
- type PreCFunction = State -> IO NumResults
- type HaskellFunction e = LuaE e NumResults
- newtype LuaBool = LuaBool CInt
- fromLuaBool :: LuaBool -> Bool
- toLuaBool :: Bool -> LuaBool
- newtype Integer = Integer Int64
- newtype Number = Number Double
- newtype StackIndex = StackIndex {
  - fromStackIndex :: CInt
  }
- registryindex :: StackIndex
- newtype NumArgs = NumArgs {
  - fromNumArgs :: CInt
  }
- newtype NumResults = NumResults {
  - fromNumResults :: CInt
  }
- multret :: NumResults
- data RelationalOperator
  - = EQ
  - | LT
  - | LE
- fromRelationalOperator :: RelationalOperator -> OPCode
- data Status
  - = OK
  - | Yield
  - | ErrRun
  - | ErrSyntax
  - | ErrMem
  - | ErrErr
  - | ErrFile
- toStatus :: StatusCode -> Status
- data Reference
  - = Reference CInt
  - | RefNil
- fromReference :: Reference -> CInt
- toReference :: CInt -> Reference
- noref :: Int
- refnil :: Int
- nthTop :: CInt -> StackIndex
- nthBottom :: CInt -> StackIndex
- nth :: CInt -> StackIndex
- top :: StackIndex
- newtype Name = Name {
  - fromName :: ByteString
  }

# Documentation

newtype LuaE e a #

A Lua computation. This is the base type used to run Lua programs of any kind. The Lua state is handled automatically, but can be retrieved via ``state``.

Constructors

Lua |
Fields unLua :: ReaderT LuaEnvironment IO a

#### Instances

Instances details

MonadReader LuaEnvironment (LuaE e) # |
Instance details Defined in HsLua.Core.Types Methods ask :: LuaE e LuaEnvironment # local :: (LuaEnvironment -> LuaEnvironment) -> LuaE e a -> LuaE e a # reader :: (LuaEnvironment -> a) -> LuaE e a #
MonadIO (LuaE e) # |
Instance details Defined in HsLua.Core.Types Methods liftIO :: IO a -> LuaE e a #
MonadCatch (LuaE e) # |
Instance details Defined in HsLua.Core.Types Methods catch :: (HasCallStack, Exception e0) => LuaE e a -> (e0 -> LuaE e a) -> LuaE e a #
MonadMask (LuaE e) # |
Instance details Defined in HsLua.Core.Types Methods mask :: HasCallStack => ((forall a. LuaE e a -> LuaE e a) -> LuaE e b) -> LuaE e b # uninterruptibleMask :: HasCallStack => ((forall a. LuaE e a -> LuaE e a) -> LuaE e b) -> LuaE e b # generalBracket :: HasCallStack => LuaE e a -> (a -> ExitCase b -> LuaE e c) -> (a -> LuaE e b) -> LuaE e (b, c) #
MonadThrow (LuaE e) # |
Instance details Defined in HsLua.Core.Types Methods throwM :: (HasCallStack, Exception e0) => e0 -> LuaE e a #
LuaError e => Alternative (LuaE e) # |
Instance details Defined in HsLua.Core.Error Methods empty :: LuaE e a # (<|>) :: LuaE e a -> LuaE e a -> LuaE e a # some :: LuaE e a -> LuaE e [a] # many :: LuaE e a -> LuaE e [a] #
Applicative (LuaE e) # |
Instance details Defined in HsLua.Core.Types Methods pure :: a -> LuaE e a # (<*>) :: LuaE e (a -> b) -> LuaE e a -> LuaE e b # liftA2 :: (a -> b -> c) -> LuaE e a -> LuaE e b -> LuaE e c # (*>) :: LuaE e a -> LuaE e b -> LuaE e b # (<*) :: LuaE e a -> LuaE e b -> LuaE e a #
Functor (LuaE e) # |
Instance details Defined in HsLua.Core.Types Methods fmap :: (a -> b) -> LuaE e a -> LuaE e b # (<$) :: a -> LuaE e b -> LuaE e a #
Monad (LuaE e) # |
Instance details Defined in HsLua.Core.Types Methods (>>=) :: LuaE e a -> (a -> LuaE e b) -> LuaE e b # (>>) :: LuaE e a -> LuaE e b -> LuaE e b # return :: a -> LuaE e a #
LuaError e => MonadFail (LuaE e) # |
Instance details Defined in HsLua.Core.Error Methods fail :: String -> LuaE e a #

newtype LuaEnvironment #

Environment in which Lua computations are evaluated.

Constructors

LuaEnvironment |
Fields luaEnvState :: State Lua interpreter state

#### Instances

Instances details

MonadReader LuaEnvironment (LuaE e) # |
Instance details Defined in HsLua.Core.Types Methods ask :: LuaE e LuaEnvironment # local :: (LuaEnvironment -> LuaEnvironment) -> LuaE e a -> LuaE e a # reader :: (LuaEnvironment -> a) -> LuaE e a #

newtype State #

An opaque structure that points to a thread and indirectly (through the thread) to the whole state of a Lua interpreter. The Lua library is fully reentrant: it has no global variables. All information about a state is accessible through this structure.

Synonym for `lua_State *`. See lua_State.

Constructors

State (Ptr ()) |

#### Instances

Instances details

Generic State |
Instance details Defined in Lua.Types Associated Types
type Rep State |
Instance details Defined in Lua.Types type Rep State = D1 ('MetaData "State" "Lua.Types" "lua-2.3.3-4jWjPpu4zMu97sTfBSZCE4" 'True) (C1 ('MetaCons "State" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Ptr ()))))
Methods from :: State -> Rep State x # to :: Rep State x -> State #
Eq State |
Instance details Defined in Lua.Types Methods (==) :: State -> State -> Bool # (/=) :: State -> State -> Bool #
type Rep State |
Instance details Defined in Lua.Types type Rep State = D1 ('MetaData "State" "Lua.Types" "lua-2.3.3-4jWjPpu4zMu97sTfBSZCE4" 'True) (C1 ('MetaCons "State" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Ptr ()))))

type Reader = FunPtr (State -> Ptr () -> Ptr CSize -> IO (Ptr CChar)) #

The reader function used by ``load``. Every time it needs another piece of the chunk, lua_load calls the reader, passing along its data parameter. The reader must return a pointer to a block of memory with a new piece of the chunk and set size to the block size. The block must exist until the reader function is called again. To signal the end of the chunk, the reader must return `NULL` or set size to zero. The reader function may return pieces of any size greater than zero.

See lua_Reader.

liftLua :: (State -> IO a) -> LuaE e a #

Turn a function of typ `Lua.State -> IO a` into a monadic Lua operation.

liftLua1 :: (State -> a -> IO b) -> a -> LuaE e b #

Turn a function of typ `Lua.State -> a -> IO b` into a monadic Lua operation.

state :: LuaE e State #

Get the Lua state of this Lua computation.

runWith :: State -> LuaE e a -> IO a #

Run Lua computation with the given Lua state. Exception handling is left to the caller; resulting exceptions are left unhandled.

unsafeRunWith :: State -> LuaE e a -> IO a #

Run the given operation, but crash if any Haskell exceptions occur.

This function is identical to `runWith`; it exists for backwards compatibility.

data GCControl #

Commands to control the garbage collector.

Constructors

GCStop | stops the garbage collector.
GCRestart | restarts the garbage collector
GCCollect | performs a full garbage-collection cycle.
GCCount | returns the current amount of memory (in Kbytes) in use by Lua.
GCCountb | returns the remainder of dividing the current amount of bytes of memory in use by Lua by 1024.
GCStep CInt | performs an incremental step of garbage collection, corresponding to the allocation of `stepsize` Kbytes.
GCInc CInt CInt CInt | Changes the collector to incremental mode with the given parameters (see <https://www.lua.org/manual/5.4/manual.html#2.5.1 §2.5.1>). Returns the previous mode (`LUA_GCGEN` or `LUA_GCINC`). Parameters: pause, stepmul, and stepsize.
GCGen CInt CInt | Changes the collector to generational mode with the given parameters (see <https://www.lua.org/manual/5.4/manual.html#2.5.2 §2.5.2>). Returns the previous mode (`LUA_GCGEN` or `LUA_GCINC`).
GCIsRunning | returns a boolean that tells whether the collector is running (i.e., not stopped).

#### Instances

Instances details

Show GCControl # |
Instance details Defined in HsLua.Core.Types Methods showsPrec :: Int -> GCControl -> ShowS # show :: GCControl -> String # showList :: [GCControl] -> ShowS #
Eq GCControl # |
Instance details Defined in HsLua.Core.Types Methods (==) :: GCControl -> GCControl -> Bool # (/=) :: GCControl -> GCControl -> Bool #
Ord GCControl # |
Instance details Defined in HsLua.Core.Types Methods compare :: GCControl -> GCControl -> Ordering # (<) :: GCControl -> GCControl -> Bool # (<=) :: GCControl -> GCControl -> Bool # (>) :: GCControl -> GCControl -> Bool # (>=) :: GCControl -> GCControl -> Bool # max :: GCControl -> GCControl -> GCControl # min :: GCControl -> GCControl -> GCControl #

toGCcode :: GCControl -> GCCode #

Converts a GCControl command to its corresponding code.

toGCdata :: GCControl -> (CInt, CInt, CInt) #

Returns the data value associated with a GCControl command.

data Type #

Enumeration used as type tag. See lua_type.

Constructors

TypeNone | non-valid stack index
TypeNil | type of Lua's `nil` value
TypeBoolean | type of Lua booleans
TypeLightUserdata | type of light userdata
TypeNumber | type of Lua numbers. See ``Number``
TypeString | type of Lua string values
TypeTable | type of Lua tables
TypeFunction | type of functions, either normal or ``CFunction``
TypeUserdata | type of full user data
TypeThread | type of Lua threads

#### Instances

Instances details

Bounded Type # |
Instance details Defined in HsLua.Core.Types Methods minBound :: Type # maxBound :: Type #
Enum Type # |
Instance details Defined in HsLua.Core.Types Methods succ :: Type -> Type # pred :: Type -> Type # toEnum :: Int -> Type # fromEnum :: Type -> Int # enumFrom :: Type -> [Type] # enumFromThen :: Type -> Type -> [Type] # enumFromTo :: Type -> Type -> [Type] # enumFromThenTo :: Type -> Type -> Type -> [Type] #
Read Type # |
Instance details Defined in HsLua.Core.Types Methods readsPrec :: Int -> ReadS Type # readList :: ReadS [Type] # readPrec :: ReadPrec Type # readListPrec :: ReadPrec [Type] #
Show Type # |
Instance details Defined in HsLua.Core.Types Methods showsPrec :: Int -> Type -> ShowS # show :: Type -> String # showList :: [Type] -> ShowS #
Eq Type # |
Instance details Defined in HsLua.Core.Types Methods (==) :: Type -> Type -> Bool # (/=) :: Type -> Type -> Bool #
Ord Type # |
Instance details Defined in HsLua.Core.Types Methods compare :: Type -> Type -> Ordering # (<) :: Type -> Type -> Bool # (<=) :: Type -> Type -> Bool # (>) :: Type -> Type -> Bool # (>=) :: Type -> Type -> Bool # max :: Type -> Type -> Type # min :: Type -> Type -> Type #

fromType :: Type -> TypeCode #

Convert a Lua `Type` to a type code which can be passed to the C API.

toType :: TypeCode -> Type #

Convert numerical code to Lua `Type`.

liftIO :: MonadIO m => IO a -> m a #

Lift a computation from the `IO` monad. This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations (i.e. `IO` is the base monad for the stack).

### Example

Expand

    import Control.Monad.Trans.State -- from the "transformers" library

    printState :: Show s => StateT s IO ()
    printState = do
      state <- get
      liftIO $ print state

Had we omitted ``liftIO``, we would have ended up with this error:

    • Couldn't match type ‘IO’ with ‘StateT s IO’
     Expected type: StateT s IO ()
       Actual type: IO ()

The important part here is the mismatch between `StateT s IO ()` and ``IO` ()`.

Luckily, we know of a function that takes an ``IO` a` and returns an `(m a)`: ``liftIO``, enabling us to run the program and see the expected results:

    > evalStateT printState "hello"
    "hello"

    > evalStateT printState 3
    3

type CFunction = FunPtr PreCFunction #

Type for C functions.

In order to communicate properly with Lua, a C function must use the following protocol, which defines the way parameters and results are passed: a C function receives its arguments from Lua in its stack in direct order (the first argument is pushed first). So, when the function starts, ``lua_gettop`` returns the number of arguments received by the function. The first argument (if any) is at index 1 and its last argument is at index ``lua_gettop``. To return values to Lua, a C function just pushes them onto the stack, in direct order (the first result is pushed first), and returns the number of results. Any other value in the stack below the results will be properly discarded by Lua. Like a Lua function, a C function called by Lua can also return many results.

See lua_CFunction.

type PreCFunction = State -> IO NumResults #

Type of Haskell functions that can be turned into C functions.

This is the same as a dereferenced `CFunction`.

type HaskellFunction e = LuaE e NumResults #

Haskell function that can be called from Lua. The HsLua equivallent of a `PreCFunction`.

newtype LuaBool #

Boolean value returned by a Lua C API function. This is a ``CInt`` and should be interpreted as ``False`` iff the value is `0`, ``True`` otherwise.

Constructors

LuaBool CInt |

#### Instances

Instances details

Storable LuaBool |
Instance details Defined in Lua.Types Methods sizeOf :: LuaBool -> Int # alignment :: LuaBool -> Int # peekElemOff :: Ptr LuaBool -> Int -> IO LuaBool # pokeElemOff :: Ptr LuaBool -> Int -> LuaBool -> IO () # peekByteOff :: Ptr b -> Int -> IO LuaBool # pokeByteOff :: Ptr b -> Int -> LuaBool -> IO () # peek :: Ptr LuaBool -> IO LuaBool # poke :: Ptr LuaBool -> LuaBool -> IO () #
Show LuaBool |
Instance details Defined in Lua.Types Methods showsPrec :: Int -> LuaBool -> ShowS # show :: LuaBool -> String # showList :: [LuaBool] -> ShowS #
Eq LuaBool |
Instance details Defined in Lua.Types Methods (==) :: LuaBool -> LuaBool -> Bool # (/=) :: LuaBool -> LuaBool -> Bool #

fromLuaBool :: LuaBool -> Bool #

Convert a ``LuaBool`` to a Haskell ``Bool``.

toLuaBool :: Bool -> LuaBool #

Convert a Haskell ``Bool`` to a ``LuaBool``.

newtype Integer #

The type of integers in Lua.

By default this type is ``Int64``, but that can be changed to different values in Lua. (See `LUA_INT_TYPE` in `luaconf.h`.)

See lua_Integer.

Constructors

Integer Int64 |

#### Instances

Instances details

Bounded Integer |
Instance details Defined in Lua.Types Methods minBound :: Integer # maxBound :: Integer #
Enum Integer |
Instance details Defined in Lua.Types Methods succ :: Integer -> Integer # pred :: Integer -> Integer # toEnum :: Int -> Integer # fromEnum :: Integer -> Int # enumFrom :: Integer -> [Integer] # enumFromThen :: Integer -> Integer -> [Integer] # enumFromTo :: Integer -> Integer -> [Integer] # enumFromThenTo :: Integer -> Integer -> Integer -> [Integer] #
Num Integer |
Instance details Defined in Lua.Types Methods (+) :: Integer -> Integer -> Integer # (-) :: Integer -> Integer -> Integer # (*) :: Integer -> Integer -> Integer # negate :: Integer -> Integer # abs :: Integer -> Integer # signum :: Integer -> Integer # fromInteger :: Integer -> Integer #
Read Integer |
Instance details Defined in Lua.Types Methods readsPrec :: Int -> ReadS Integer # readList :: ReadS [Integer] # readPrec :: ReadPrec Integer # readListPrec :: ReadPrec [Integer] #
Integral Integer |
Instance details Defined in Lua.Types Methods quot :: Integer -> Integer -> Integer # rem :: Integer -> Integer -> Integer # div :: Integer -> Integer -> Integer # mod :: Integer -> Integer -> Integer # quotRem :: Integer -> Integer -> (Integer, Integer) # divMod :: Integer -> Integer -> (Integer, Integer) # toInteger :: Integer -> Integer #
Real Integer |
Instance details Defined in Lua.Types Methods toRational :: Integer -> Rational #
Show Integer |
Instance details Defined in Lua.Types Methods showsPrec :: Int -> Integer -> ShowS # show :: Integer -> String # showList :: [Integer] -> ShowS #
Eq Integer |
Instance details Defined in Lua.Types Methods (==) :: Integer -> Integer -> Bool # (/=) :: Integer -> Integer -> Bool #
Ord Integer |
Instance details Defined in Lua.Types Methods compare :: Integer -> Integer -> Ordering # (<) :: Integer -> Integer -> Bool # (<=) :: Integer -> Integer -> Bool # (>) :: Integer -> Integer -> Bool # (>=) :: Integer -> Integer -> Bool # max :: Integer -> Integer -> Integer # min :: Integer -> Integer -> Integer #

newtype Number #

The type of floats in Lua.

By default this type is ``Double``, but that can be changed in Lua to a single float or a long double. (See `LUA_FLOAT_TYPE` in `luaconf.h`.)

See lua_Number.

Constructors

Number Double |

#### Instances

Instances details

Floating Number |
Instance details Defined in Lua.Types Methods pi :: Number # exp :: Number -> Number # log :: Number -> Number # sqrt :: Number -> Number # (**) :: Number -> Number -> Number # logBase :: Number -> Number -> Number # sin :: Number -> Number # cos :: Number -> Number # tan :: Number -> Number # asin :: Number -> Number # acos :: Number -> Number # atan :: Number -> Number # sinh :: Number -> Number # cosh :: Number -> Number # tanh :: Number -> Number # asinh :: Number -> Number # acosh :: Number -> Number # atanh :: Number -> Number # log1p :: Number -> Number # expm1 :: Number -> Number # log1pexp :: Number -> Number # log1mexp :: Number -> Number #
RealFloat Number |
Instance details Defined in Lua.Types Methods floatRadix :: Number -> Integer # floatDigits :: Number -> Int # floatRange :: Number -> (Int, Int) # decodeFloat :: Number -> (Integer, Int) # encodeFloat :: Integer -> Int -> Number # exponent :: Number -> Int # significand :: Number -> Number # scaleFloat :: Int -> Number -> Number # isNaN :: Number -> Bool # isInfinite :: Number -> Bool # isDenormalized :: Number -> Bool # isNegativeZero :: Number -> Bool # isIEEE :: Number -> Bool # atan2 :: Number -> Number -> Number #
Num Number |
Instance details Defined in Lua.Types Methods (+) :: Number -> Number -> Number # (-) :: Number -> Number -> Number # (*) :: Number -> Number -> Number # negate :: Number -> Number # abs :: Number -> Number # signum :: Number -> Number # fromInteger :: Integer -> Number #
Read Number |
Instance details Defined in Lua.Types Methods readsPrec :: Int -> ReadS Number # readList :: ReadS [Number] # readPrec :: ReadPrec Number # readListPrec :: ReadPrec [Number] #
Fractional Number |
Instance details Defined in Lua.Types Methods (/) :: Number -> Number -> Number # recip :: Number -> Number # fromRational :: Rational -> Number #
Real Number |
Instance details Defined in Lua.Types Methods toRational :: Number -> Rational #
RealFrac Number |
Instance details Defined in Lua.Types Methods properFraction :: Integral b => Number -> (b, Number) # truncate :: Integral b => Number -> b # round :: Integral b => Number -> b # ceiling :: Integral b => Number -> b # floor :: Integral b => Number -> b #
Show Number |
Instance details Defined in Lua.Types Methods showsPrec :: Int -> Number -> ShowS # show :: Number -> String # showList :: [Number] -> ShowS #
Eq Number |
Instance details Defined in Lua.Types Methods (==) :: Number -> Number -> Bool # (/=) :: Number -> Number -> Bool #
Ord Number |
Instance details Defined in Lua.Types Methods compare :: Number -> Number -> Ordering # (<) :: Number -> Number -> Bool # (<=) :: Number -> Number -> Bool # (>) :: Number -> Number -> Bool # (>=) :: Number -> Number -> Bool # max :: Number -> Number -> Number # min :: Number -> Number -> Number #

newtype StackIndex #

A stack index

Constructors

StackIndex |
Fields fromStackIndex :: CInt

#### Instances

Instances details

Enum StackIndex |
Instance details Defined in Lua.Types Methods succ :: StackIndex -> StackIndex # pred :: StackIndex -> StackIndex # toEnum :: Int -> StackIndex # fromEnum :: StackIndex -> Int # enumFrom :: StackIndex -> [StackIndex] # enumFromThen :: StackIndex -> StackIndex -> [StackIndex] # enumFromTo :: StackIndex -> StackIndex -> [StackIndex] # enumFromThenTo :: StackIndex -> StackIndex -> StackIndex -> [StackIndex] #
Num StackIndex |
Instance details Defined in Lua.Types Methods (+) :: StackIndex -> StackIndex -> StackIndex # (-) :: StackIndex -> StackIndex -> StackIndex # (*) :: StackIndex -> StackIndex -> StackIndex # negate :: StackIndex -> StackIndex # abs :: StackIndex -> StackIndex # signum :: StackIndex -> StackIndex # fromInteger :: Integer -> StackIndex #
Show StackIndex |
Instance details Defined in Lua.Types Methods showsPrec :: Int -> StackIndex -> ShowS # show :: StackIndex -> String # showList :: [StackIndex] -> ShowS #
Eq StackIndex |
Instance details Defined in Lua.Types Methods (==) :: StackIndex -> StackIndex -> Bool # (/=) :: StackIndex -> StackIndex -> Bool #
Ord StackIndex |
Instance details Defined in Lua.Types Methods compare :: StackIndex -> StackIndex -> Ordering # (<) :: StackIndex -> StackIndex -> Bool # (<=) :: StackIndex -> StackIndex -> Bool # (>) :: StackIndex -> StackIndex -> Bool # (>=) :: StackIndex -> StackIndex -> Bool # max :: StackIndex -> StackIndex -> StackIndex # min :: StackIndex -> StackIndex -> StackIndex #

registryindex :: StackIndex #

Pseudo stack index of the Lua registry.

newtype NumArgs #

The number of arguments consumed curing a function call.

Constructors

NumArgs |
Fields fromNumArgs :: CInt

#### Instances

Instances details

Num NumArgs |
Instance details Defined in Lua.Types Methods (+) :: NumArgs -> NumArgs -> NumArgs # (-) :: NumArgs -> NumArgs -> NumArgs # (*) :: NumArgs -> NumArgs -> NumArgs # negate :: NumArgs -> NumArgs # abs :: NumArgs -> NumArgs # signum :: NumArgs -> NumArgs # fromInteger :: Integer -> NumArgs #
Show NumArgs |
Instance details Defined in Lua.Types Methods showsPrec :: Int -> NumArgs -> ShowS # show :: NumArgs -> String # showList :: [NumArgs] -> ShowS #
Eq NumArgs |
Instance details Defined in Lua.Types Methods (==) :: NumArgs -> NumArgs -> Bool # (/=) :: NumArgs -> NumArgs -> Bool #
Ord NumArgs |
Instance details Defined in Lua.Types Methods compare :: NumArgs -> NumArgs -> Ordering # (<) :: NumArgs -> NumArgs -> Bool # (<=) :: NumArgs -> NumArgs -> Bool # (>) :: NumArgs -> NumArgs -> Bool # (>=) :: NumArgs -> NumArgs -> Bool # max :: NumArgs -> NumArgs -> NumArgs # min :: NumArgs -> NumArgs -> NumArgs #

newtype NumResults #

The number of results returned by a function call.

Constructors

NumResults |
Fields fromNumResults :: CInt

#### Instances

Instances details

Num NumResults |
Instance details Defined in Lua.Types Methods (+) :: NumResults -> NumResults -> NumResults # (-) :: NumResults -> NumResults -> NumResults # (*) :: NumResults -> NumResults -> NumResults # negate :: NumResults -> NumResults # abs :: NumResults -> NumResults # signum :: NumResults -> NumResults # fromInteger :: Integer -> NumResults #
Show NumResults |
Instance details Defined in Lua.Types Methods showsPrec :: Int -> NumResults -> ShowS # show :: NumResults -> String # showList :: [NumResults] -> ShowS #
Eq NumResults |
Instance details Defined in Lua.Types Methods (==) :: NumResults -> NumResults -> Bool # (/=) :: NumResults -> NumResults -> Bool #
Ord NumResults |
Instance details Defined in Lua.Types Methods compare :: NumResults -> NumResults -> Ordering # (<) :: NumResults -> NumResults -> Bool # (<=) :: NumResults -> NumResults -> Bool # (>) :: NumResults -> NumResults -> Bool # (>=) :: NumResults -> NumResults -> Bool # max :: NumResults -> NumResults -> NumResults # min :: NumResults -> NumResults -> NumResults #

multret :: NumResults #

Option for multiple returns in ``pcall``.

data RelationalOperator #

Lua comparison operations.

Constructors

EQ | Correponds to Lua's equality (==) operator.
LT | Correponds to Lua's strictly-lesser-than (<) operator
LE | Correponds to Lua's lesser-or-equal (<=) operator

#### Instances

Instances details

Show RelationalOperator # |
Instance details Defined in HsLua.Core.Types Methods showsPrec :: Int -> RelationalOperator -> ShowS # show :: RelationalOperator -> String # showList :: [RelationalOperator] -> ShowS #
Eq RelationalOperator # |
Instance details Defined in HsLua.Core.Types Methods (==) :: RelationalOperator -> RelationalOperator -> Bool # (/=) :: RelationalOperator -> RelationalOperator -> Bool #
Ord RelationalOperator # |
Instance details Defined in HsLua.Core.Types Methods compare :: RelationalOperator -> RelationalOperator -> Ordering # (<) :: RelationalOperator -> RelationalOperator -> Bool # (<=) :: RelationalOperator -> RelationalOperator -> Bool # (>) :: RelationalOperator -> RelationalOperator -> Bool # (>=) :: RelationalOperator -> RelationalOperator -> Bool # max :: RelationalOperator -> RelationalOperator -> RelationalOperator # min :: RelationalOperator -> RelationalOperator -> RelationalOperator #

fromRelationalOperator :: RelationalOperator -> OPCode #

Convert relation operator to its C representation.

data Status #

Lua status values.

Constructors

OK | success
Yield | yielding / suspended coroutine
ErrRun | a runtime rror
ErrSyntax | syntax error during precompilation
ErrMem | memory allocation (out-of-memory) error.
ErrErr | error while running the message handler.
ErrFile | opening or reading a file failed.

#### Instances

Instances details

Show Status # |
Instance details Defined in HsLua.Core.Types Methods showsPrec :: Int -> Status -> ShowS # show :: Status -> String # showList :: [Status] -> ShowS #
Eq Status # |
Instance details Defined in HsLua.Core.Types Methods (==) :: Status -> Status -> Bool # (/=) :: Status -> Status -> Bool #

toStatus :: StatusCode -> Status #

Convert C integer constant to ``Status``.

# References

data Reference #

Reference to a stored value.

Constructors

Reference CInt | Reference to a stored value
RefNil | Reference to a nil value

#### Instances

Instances details

Show Reference |
Instance details Defined in Lua.Auxiliary Methods showsPrec :: Int -> Reference -> ShowS # show :: Reference -> String # showList :: [Reference] -> ShowS #
Eq Reference |
Instance details Defined in Lua.Auxiliary Methods (==) :: Reference -> Reference -> Bool # (/=) :: Reference -> Reference -> Bool #

fromReference :: Reference -> CInt #

Convert a reference to its C representation.

toReference :: CInt -> Reference #

Create a reference from its C representation.

noref :: Int #

Value signaling that no reference was found.

refnil :: Int #

Value signaling that no reference was created.

# Stack index helpers

nthTop :: CInt -> StackIndex #

Stack index of the nth element from the top of the stack.

Since: lua-2.0.0

nthBottom :: CInt -> StackIndex #

Stack index of the nth element from the bottom of the stack.

Since: lua-2.0.0

nth :: CInt -> StackIndex #

Alias for `nthTop`.

Since: lua-2.0.0

top :: StackIndex #

Index of the topmost stack element.

Since: lua-2.0.0

# Table field names

newtype Name #

Name of a function, table field, or chunk; the name must be valid UTF-8 and may not contain any nul characters.

Implementation note: this is a `newtype` instead of a simple `type Name = ByteString` alias so we can define a UTF-8 based `IsString` instance. Non-ASCII users would have a bad time otherwise.

Constructors

Name |
Fields fromName :: ByteString

#### Instances

Instances details

Semigroup Name # |
Instance details Defined in HsLua.Core.Types Methods (<>) :: Name -> Name -> Name # sconcat :: NonEmpty Name -> Name # stimes :: Integral b => b -> Name -> Name #
IsString Name # |
Instance details Defined in HsLua.Core.Types Methods fromString :: String -> Name #
Show Name # |
Instance details Defined in HsLua.Core.Types Methods showsPrec :: Int -> Name -> ShowS # show :: Name -> String # showList :: [Name] -> ShowS #
Eq Name # |
Instance details Defined in HsLua.Core.Types Methods (==) :: Name -> Name -> Bool # (/=) :: Name -> Name -> Bool #
Ord Name # |
Instance details Defined in HsLua.Core.Types Methods compare :: Name -> Name -> Ordering # (<) :: Name -> Name -> Bool # (<=) :: Name -> Name -> Bool # (>) :: Name -> Name -> Bool # (>=) :: Name -> Name -> Bool # max :: Name -> Name -> Name # min :: Name -> Name -> Name #