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 Source #

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

newtype LuaEnvironment Source #

Environment in which Lua computations are evaluated.

Constructors

LuaEnvironment |

Fields

- luaEnvState :: State

  Lua interpreter state

#### Instances

Instances details

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

newtype State Source #

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.4-9jycuNWuw7q13eGe6UuFpA" 'True) (C1 ('MetaCons "State" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Ptr ()))))

Methods

from :: State -> Rep State x Source #

to :: Rep State x -> State Source #

Eq State |
Instance details Defined in Lua.Types Methods (==) :: State -> State -> Bool Source # (/=) :: State -> State -> Bool Source #
type Rep State |
Instance details Defined in Lua.Types type Rep State = D1 ('MetaData "State" "Lua.Types" "lua-2.3.4-9jycuNWuw7q13eGe6UuFpA" '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)) Source #

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 Source #

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

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

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

state :: LuaE e State Source #

Get the Lua state of this Lua computation.

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

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 Source #

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

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

data GCControl Source #

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 Source # |
Instance details Defined in HsLua.Core.Types Methods showsPrec :: Int -> GCControl -> ShowS Source # show :: GCControl -> String Source # showList :: [GCControl] -> ShowS Source #
Eq GCControl Source # |
Instance details Defined in HsLua.Core.Types Methods (==) :: GCControl -> GCControl -> Bool Source # (/=) :: GCControl -> GCControl -> Bool Source #
Ord GCControl Source # |

Instance details

Defined in HsLua.Core.Types

Methods

compare :: GCControl -> GCControl -> Ordering Source #

(<) :: GCControl -> GCControl -> Bool Source #

(<=) :: GCControl -> GCControl -> Bool Source #

(>) :: GCControl -> GCControl -> Bool Source #

(>=) :: GCControl -> GCControl -> Bool Source #

max :: GCControl -> GCControl -> GCControl Source #

min :: GCControl -> GCControl -> GCControl Source #

toGCcode :: GCControl -> GCCode Source #

Converts a GCControl command to its corresponding code.

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

Returns the data value associated with a GCControl command.

data Type Source #

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

fromType :: Type -> TypeCode Source #

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

toType :: TypeCode -> Type Source #

Convert numerical code to Lua `Type`.

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

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 Source #

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 Source #

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 Source #

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

newtype LuaBool Source #

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 Source #

alignment :: LuaBool -> Int Source #

peekElemOff :: Ptr LuaBool -> Int -> IO LuaBool Source #

pokeElemOff :: Ptr LuaBool -> Int -> LuaBool -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO LuaBool Source #

pokeByteOff :: Ptr b -> Int -> LuaBool -> IO () Source #

peek :: Ptr LuaBool -> IO LuaBool Source #

poke :: Ptr LuaBool -> LuaBool -> IO () Source #

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

fromLuaBool :: LuaBool -> Bool Source #

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

toLuaBool :: Bool -> LuaBool Source #

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

newtype Integer Source #

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 Source # maxBound :: Integer Source #
Enum Integer |

Instance details

Defined in Lua.Types

Methods

succ :: Integer -> Integer Source #

pred :: Integer -> Integer Source #

toEnum :: Int -> Integer Source #

fromEnum :: Integer -> Int Source #

enumFrom :: Integer -> [Integer] Source #

enumFromThen :: Integer -> Integer -> [Integer] Source #

enumFromTo :: Integer -> Integer -> [Integer] Source #

enumFromThenTo :: Integer -> Integer -> Integer -> [Integer] Source #

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

newtype Number Source #

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 Source #

exp :: Number -> Number Source #

log :: Number -> Number Source #

sqrt :: Number -> Number Source #

(**) :: Number -> Number -> Number Source #

logBase :: Number -> Number -> Number Source #

sin :: Number -> Number Source #

cos :: Number -> Number Source #

tan :: Number -> Number Source #

asin :: Number -> Number Source #

acos :: Number -> Number Source #

atan :: Number -> Number Source #

sinh :: Number -> Number Source #

cosh :: Number -> Number Source #

tanh :: Number -> Number Source #

asinh :: Number -> Number Source #

acosh :: Number -> Number Source #

atanh :: Number -> Number Source #

log1p :: Number -> Number Source #

expm1 :: Number -> Number Source #

log1pexp :: Number -> Number Source #

log1mexp :: Number -> Number Source #

RealFloat Number |

Instance details

Defined in Lua.Types

Methods

floatRadix :: Number -> Integer Source #

floatDigits :: Number -> Int Source #

floatRange :: Number -> (Int, Int) Source #

decodeFloat :: Number -> (Integer, Int) Source #

encodeFloat :: Integer -> Int -> Number Source #

exponent :: Number -> Int Source #

significand :: Number -> Number Source #

scaleFloat :: Int -> Number -> Number Source #

isNaN :: Number -> Bool Source #

isInfinite :: Number -> Bool Source #

isDenormalized :: Number -> Bool Source #

isNegativeZero :: Number -> Bool Source #

isIEEE :: Number -> Bool Source #

atan2 :: Number -> Number -> Number Source #

Num Number |
Instance details Defined in Lua.Types Methods (+) :: Number -> Number -> Number Source # (-) :: Number -> Number -> Number Source # (*) :: Number -> Number -> Number Source # negate :: Number -> Number Source # abs :: Number -> Number Source # signum :: Number -> Number Source # fromInteger :: Integer -> Number Source #
Read Number |
Instance details Defined in Lua.Types Methods readsPrec :: Int -> ReadS Number Source # readList :: ReadS [Number] Source # readPrec :: ReadPrec Number Source # readListPrec :: ReadPrec [Number] Source #
Fractional Number |
Instance details Defined in Lua.Types Methods (/) :: Number -> Number -> Number Source # recip :: Number -> Number Source # fromRational :: Rational -> Number Source #
Real Number |
Instance details Defined in Lua.Types Methods toRational :: Number -> Rational Source #
RealFrac Number |
Instance details Defined in Lua.Types Methods properFraction :: Integral b => Number -> (b, Number) Source # truncate :: Integral b => Number -> b Source # round :: Integral b => Number -> b Source # ceiling :: Integral b => Number -> b Source # floor :: Integral b => Number -> b Source #
Show Number |
Instance details Defined in Lua.Types Methods showsPrec :: Int -> Number -> ShowS Source # show :: Number -> String Source # showList :: [Number] -> ShowS Source #
Eq Number |
Instance details Defined in Lua.Types Methods (==) :: Number -> Number -> Bool Source # (/=) :: Number -> Number -> Bool Source #
Ord Number |
Instance details Defined in Lua.Types Methods compare :: Number -> Number -> Ordering Source # (<) :: Number -> Number -> Bool Source # (<=) :: Number -> Number -> Bool Source # (>) :: Number -> Number -> Bool Source # (>=) :: Number -> Number -> Bool Source # max :: Number -> Number -> Number Source # min :: Number -> Number -> Number Source #

newtype StackIndex Source #

A stack index

Constructors

StackIndex |

Fields

- fromStackIndex :: CInt

#### Instances

Instances details

Enum StackIndex |

Instance details

Defined in Lua.Types

Methods

succ :: StackIndex -> StackIndex Source #

pred :: StackIndex -> StackIndex Source #

toEnum :: Int -> StackIndex Source #

fromEnum :: StackIndex -> Int Source #

enumFrom :: StackIndex -> [StackIndex] Source #

enumFromThen :: StackIndex -> StackIndex -> [StackIndex] Source #

enumFromTo :: StackIndex -> StackIndex -> [StackIndex] Source #

enumFromThenTo :: StackIndex -> StackIndex -> StackIndex -> [StackIndex] Source #

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

Instance details

Defined in Lua.Types

Methods

compare :: StackIndex -> StackIndex -> Ordering Source #

(<) :: StackIndex -> StackIndex -> Bool Source #

(<=) :: StackIndex -> StackIndex -> Bool Source #

(>) :: StackIndex -> StackIndex -> Bool Source #

(>=) :: StackIndex -> StackIndex -> Bool Source #

max :: StackIndex -> StackIndex -> StackIndex Source #

min :: StackIndex -> StackIndex -> StackIndex Source #

registryindex :: StackIndex Source #

Pseudo stack index of the Lua registry.

newtype NumArgs Source #

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

newtype NumResults Source #

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 Source # (-) :: NumResults -> NumResults -> NumResults Source # (*) :: NumResults -> NumResults -> NumResults Source # negate :: NumResults -> NumResults Source # abs :: NumResults -> NumResults Source # signum :: NumResults -> NumResults Source # fromInteger :: Integer -> NumResults Source #
Show NumResults |
Instance details Defined in Lua.Types Methods showsPrec :: Int -> NumResults -> ShowS Source # show :: NumResults -> String Source # showList :: [NumResults] -> ShowS Source #
Eq NumResults |
Instance details Defined in Lua.Types Methods (==) :: NumResults -> NumResults -> Bool Source # (/=) :: NumResults -> NumResults -> Bool Source #
Ord NumResults |

Instance details

Defined in Lua.Types

Methods

compare :: NumResults -> NumResults -> Ordering Source #

(<) :: NumResults -> NumResults -> Bool Source #

(<=) :: NumResults -> NumResults -> Bool Source #

(>) :: NumResults -> NumResults -> Bool Source #

(>=) :: NumResults -> NumResults -> Bool Source #

max :: NumResults -> NumResults -> NumResults Source #

min :: NumResults -> NumResults -> NumResults Source #

multret :: NumResults Source #

Option for multiple returns in ``pcall``.

data RelationalOperator Source #

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 Source # |
Instance details Defined in HsLua.Core.Types Methods showsPrec :: Int -> RelationalOperator -> ShowS Source # show :: RelationalOperator -> String Source # showList :: [RelationalOperator] -> ShowS Source #
Eq RelationalOperator Source # |
Instance details Defined in HsLua.Core.Types Methods (==) :: RelationalOperator -> RelationalOperator -> Bool Source # (/=) :: RelationalOperator -> RelationalOperator -> Bool Source #
Ord RelationalOperator Source # |

Instance details

Defined in HsLua.Core.Types

Methods

compare :: RelationalOperator -> RelationalOperator -> Ordering Source #

(<) :: RelationalOperator -> RelationalOperator -> Bool Source #

(<=) :: RelationalOperator -> RelationalOperator -> Bool Source #

(>) :: RelationalOperator -> RelationalOperator -> Bool Source #

(>=) :: RelationalOperator -> RelationalOperator -> Bool Source #

max :: RelationalOperator -> RelationalOperator -> RelationalOperator Source #

min :: RelationalOperator -> RelationalOperator -> RelationalOperator Source #

fromRelationalOperator :: RelationalOperator -> OPCode Source #

Convert relation operator to its C representation.

data Status Source #

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

toStatus :: StatusCode -> Status Source #

Convert C integer constant to ``Status``.

# References

data Reference Source #

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 Source # show :: Reference -> String Source # showList :: [Reference] -> ShowS Source #
Eq Reference |
Instance details Defined in Lua.Auxiliary Methods (==) :: Reference -> Reference -> Bool Source # (/=) :: Reference -> Reference -> Bool Source #

fromReference :: Reference -> CInt Source #

Convert a reference to its C representation.

toReference :: CInt -> Reference Source #

Create a reference from its C representation.

noref :: Int Source #

Value signaling that no reference was found.

refnil :: Int Source #

Value signaling that no reference was created.

# Stack index helpers

nthTop :: CInt -> StackIndex Source #

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

Since: lua-2.0.0

nthBottom :: CInt -> StackIndex Source #

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

Since: lua-2.0.0

nth :: CInt -> StackIndex Source #

Alias for `nthTop`.

Since: lua-2.0.0

top :: StackIndex Source #

Index of the topmost stack element.

Since: lua-2.0.0

# Table field names

newtype Name Source #

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