lua-2.3.4: 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

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

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 Source # |
Instance details Defined in Lua.Types Methods (==) :: State -> State -> Bool Source # (/=) :: State -> State -> Bool Source #
type Rep State Source # |
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.

newtype TypeCode Source #

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

Constructors

TypeCode |

Fields

- fromTypeCode :: CInt

#### Instances

Instances details

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

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

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

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

This is the same as a dereferenced `WarnFunction`.

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

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

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 Source # |
Instance details Defined in Lua.Types Methods minBound :: Integer Source # maxBound :: Integer Source #
Enum Integer Source # |

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

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

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 Source # |
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 Source # |
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 Source # |
Instance details Defined in Lua.Types Methods (/) :: Number -> Number -> Number Source # recip :: Number -> Number Source # fromRational :: Rational -> Number Source #
Real Number Source # |
Instance details Defined in Lua.Types Methods toRational :: Number -> Rational Source #
RealFrac Number Source # |
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 Source # |
Instance details Defined in Lua.Types Methods showsPrec :: Int -> Number -> ShowS Source # show :: Number -> String Source # showList :: [Number] -> ShowS Source #
Eq Number Source # |
Instance details Defined in Lua.Types Methods (==) :: Number -> Number -> Bool Source # (/=) :: Number -> Number -> Bool Source #
Ord Number Source # |
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 Source # |

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

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 #

newtype NumArgs Source #

The number of arguments consumed curing a function call.

Constructors

NumArgs |

Fields

- fromNumArgs :: CInt

#### Instances

Instances details

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

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 #

newtype OPCode Source #

Relational operator code.

Constructors

OPCode CInt |

#### Instances

Instances details

Storable OPCode Source # |

Instance details

Defined in Lua.Types

Methods

sizeOf :: OPCode -> Int Source #

alignment :: OPCode -> Int Source #

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

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

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

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

peek :: Ptr OPCode -> IO OPCode Source #

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

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

newtype ArithOPCode Source #

Arithmetic operator code.

Constructors

ArithOPCode CInt |

#### Instances

Instances details

Storable ArithOPCode Source # |

Instance details

Defined in Lua.Types

Methods

sizeOf :: ArithOPCode -> Int Source #

alignment :: ArithOPCode -> Int Source #

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

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

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

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

peek :: Ptr ArithOPCode -> IO ArithOPCode Source #

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

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

newtype StatusCode Source #

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

Constructors

StatusCode CInt |

#### Instances

Instances details

Storable StatusCode Source # |

Instance details

Defined in Lua.Types

Methods

sizeOf :: StatusCode -> Int Source #

alignment :: StatusCode -> Int Source #

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

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

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

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

peek :: Ptr StatusCode -> IO StatusCode Source #

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

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

# Garbage-Collection

newtype GCCode Source #

Garbage-collection options.

Constructors

GCCode CInt |

#### Instances

Instances details

Storable GCCode Source # |

Instance details

Defined in Lua.Types

Methods

sizeOf :: GCCode -> Int Source #

alignment :: GCCode -> Int Source #

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

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

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

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

peek :: Ptr GCCode -> IO GCCode Source #

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

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