Lua.Types

lua-2.3.1: Lua, an embeddable scripting language

Copyright | © 2007–2012 Gracjan Polak; © 2012–2016 Ömer Sinan Ağacan; © 2017-2023 Albert Krewinkel
License | MIT
Maintainer | Albert Krewinkel <tarleb@hslua.org>
Stability | beta
Portability | non-portable (depends on GHC)
Safe Haskell | Safe-Inferred
Language | Haskell2010

Lua.Types

Contents

- Garbage-Collection

Description

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

Synopsis

- newtype State = State (Ptr ())
- type Reader = FunPtr (State -> Ptr () -> Ptr CSize -> IO (Ptr CChar))
- newtype TypeCode = TypeCode {
  - fromTypeCode :: CInt
  }
- type CFunction = FunPtr PreCFunction
- type PreCFunction = State -> IO NumResults
- type WarnFunction = FunPtr (Ptr () -> CString -> LuaBool -> IO ())
- type PreWarnFunction = Ptr () -> CString -> LuaBool -> IO ()
- newtype LuaBool = LuaBool CInt
- newtype Integer = Integer Int64
- newtype Number = Number Double
- newtype StackIndex = StackIndex {
  - fromStackIndex :: CInt
  }
- newtype NumArgs = NumArgs {
  - fromNumArgs :: CInt
  }
- newtype NumResults = NumResults {
  - fromNumResults :: CInt
  }
- newtype OPCode = OPCode CInt
- newtype ArithOPCode = ArithOPCode CInt
- newtype StatusCode = StatusCode CInt
- newtype GCCode = GCCode CInt

# Documentation

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 :: Type -> Type 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.1-LCSpVnXLk6DUQZUIHDoqI" '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.

newtype TypeCode #

Integer code used to encode the type of a Lua value.

Constructors

TypeCode |
Fields fromTypeCode :: CInt

#### Instances

Instances details

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

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 WarnFunction = FunPtr (Ptr () -> CString -> LuaBool -> IO ()) #

The type of warning functions, called by Lua to emit warnings. The first parameter is an opaque pointer set by `lua_setwarnf`. The second parameter is the warning message. The third parameter is a boolean that indicates whether the message is to be continued by the message in the next call.

See warn for more details about warnings.

type PreWarnFunction = Ptr () -> CString -> LuaBool -> IO () #

Type of Haskell functions that can be turned into a WarnFunction.

This is the same as a dereferenced `WarnFunction`.

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

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 :: Integer0 -> 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 -> Integer0
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

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

newtype OPCode #

Relational operator code.

Constructors

OPCode CInt |

#### Instances

Instances details

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

newtype ArithOPCode #

Arithmetic operator code.

Constructors

ArithOPCode CInt |

#### Instances

Instances details

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

newtype StatusCode #

Integer code used to signal the status of a thread or computation.

Constructors

StatusCode CInt |

#### Instances

Instances details

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

# Garbage-Collection

newtype GCCode #

Garbage-collection options.

Constructors

GCCode CInt |

#### Instances

Instances details

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