hslua-1.2.0: Bindings to Lua, an embeddable scripting language

Copyright© 2007–2012 Gracjan Polak
2012–2016 Ömer Sinan Ağacan
2017-2020 Albert Krewinkel
LicenseMIT
MaintainerAlbert Krewinkel <tarleb+hslua@zeitkraut.de>
Stabilitybeta
Portabilitynon-portable (depends on GHC)
Safe HaskellNone
LanguageHaskell2010

Foreign.Lua.Raw.Types

Description

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

Synopsis

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
Eq State Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Methods

(==) :: State -> State -> Bool #

(/=) :: State -> State -> Bool #

Generic State Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Associated Types

type Rep State :: Type -> Type #

Methods

from :: State -> Rep State x #

to :: Rep State x -> State #

Pushable CFunction Source # 
Instance details

Defined in Foreign.Lua.Types.Pushable

Methods

push :: CFunction -> Lua () Source #

Peekable CFunction Source # 
Instance details

Defined in Foreign.Lua.Types.Peekable

Peekable State Source # 
Instance details

Defined in Foreign.Lua.Types.Peekable

type Rep State Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

type Rep State = D1 (MetaData "State" "Foreign.Lua.Raw.Types" "hslua-1.2.0-7ZxTR96DywwFnuAhzzhkFV" 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.

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
Bounded Type Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Enum Type Source # 
Instance details

Defined in Foreign.Lua.Raw.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] #

Eq Type Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Methods

(==) :: Type -> Type -> Bool #

(/=) :: Type -> Type -> Bool #

Ord Type Source # 
Instance details

Defined in Foreign.Lua.Raw.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 #

Show Type Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Methods

showsPrec :: Int -> Type -> ShowS #

show :: Type -> String #

showList :: [Type] -> ShowS #

newtype TypeCode Source #

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

Constructors

TypeCode 

Fields

Instances
Eq TypeCode Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Ord TypeCode Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Show TypeCode Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

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.

type CFunction = FunPtr (State -> IO NumResults) 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, 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 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.

newtype LuaBool Source #

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

Constructors

LuaBool CInt 
Instances
Eq LuaBool Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Methods

(==) :: LuaBool -> LuaBool -> Bool #

(/=) :: LuaBool -> LuaBool -> Bool #

Show LuaBool Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Storable LuaBool Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

false :: LuaBool Source #

Lua representation of the value interpreted as false.

true :: LuaBool Source #

Generic Lua representation of a value interpreted as being true.

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
Bounded Integer Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Enum Integer Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Eq Integer Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Methods

(==) :: Integer -> Integer -> Bool #

(/=) :: Integer -> Integer -> Bool #

Integral Integer Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Num Integer Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Ord Integer Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Real Integer Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Show Integer Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Pushable Integer Source # 
Instance details

Defined in Foreign.Lua.Types.Pushable

Methods

push :: Integer -> Lua () Source #

Peekable Integer Source # 
Instance details

Defined in Foreign.Lua.Types.Peekable

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
Eq Number Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Methods

(==) :: Number -> Number -> Bool #

(/=) :: Number -> Number -> Bool #

Floating Number Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Fractional Number Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Num Number Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Ord Number Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Real Number Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

RealFloat Number Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

RealFrac Number Source # 
Instance details

Defined in Foreign.Lua.Raw.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 Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Pushable Number Source # 
Instance details

Defined in Foreign.Lua.Types.Pushable

Methods

push :: Number -> Lua () Source #

Peekable Number Source # 
Instance details

Defined in Foreign.Lua.Types.Peekable

newtype StackIndex Source #

A stack index

Constructors

StackIndex 

Fields

Instances
Enum StackIndex Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Eq StackIndex Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Num StackIndex Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Ord StackIndex Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Show StackIndex Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

newtype NumArgs Source #

The number of arguments consumed curing a function call.

Constructors

NumArgs 

Fields

Instances
Eq NumArgs Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Methods

(==) :: NumArgs -> NumArgs -> Bool #

(/=) :: NumArgs -> NumArgs -> Bool #

Num NumArgs Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Ord NumArgs Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Show NumArgs Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

newtype NumResults Source #

The number of results returned by a function call.

Constructors

NumResults 

Fields

Instances
Eq NumResults Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Num NumResults Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Ord NumResults Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Show NumResults Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Pushable CFunction Source # 
Instance details

Defined in Foreign.Lua.Types.Pushable

Methods

push :: CFunction -> Lua () Source #

Peekable CFunction Source # 
Instance details

Defined in Foreign.Lua.Types.Peekable

ToHaskellFunction HaskellFunction Source # 
Instance details

Defined in Foreign.Lua.FunctionCalling

fromRelationalOperator :: RelationalOperator -> CInt 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.

ErrGcmm

error while running a __gc metamethod.

ErrFile

opening or reading a file failed.

Instances
Eq Status Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

Methods

(==) :: Status -> Status -> Bool #

(/=) :: Status -> Status -> Bool #

Show Status Source # 
Instance details

Defined in Foreign.Lua.Raw.Types

newtype StatusCode Source #

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

Constructors

StatusCode CInt 

toStatus :: StatusCode -> Status Source #

Convert C integer constant to Status.