hslua-0.9.5.2: A Lua language interpreter embedding in Haskell

Copyright© 2007–2012 Gracjan Polak
2012–2016 Ömer Sinan Ağacan
2017 Albert Krewinkel
LicenseMIT
MaintainerAlbert Krewinkel <tarleb+hslua@zeitkraut.de>
Stabilitybeta
PortabilityForeignFunctionInterface, GeneralizedNewtypeDeriving
Safe HaskellNone
LanguageHaskell98

Foreign.Lua.Api.Types

Contents

Description

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

Synopsis

Documentation

newtype LuaState #

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

LuaState (Ptr ()) 

type CFunction = FunPtr (LuaState -> IO NumResults) #

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

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

LuaInteger Int64 

Instances

Enum LuaInteger # 
Eq LuaInteger # 
Integral LuaInteger # 
Num LuaInteger # 
Ord LuaInteger # 
Real LuaInteger # 
Show LuaInteger # 
FromLuaStack LuaInteger # 
ToLuaStack LuaInteger # 

Methods

push :: LuaInteger -> Lua () #

newtype LuaNumber #

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

LuaNumber Double 

Instances

Eq LuaNumber # 
Floating LuaNumber # 
Fractional LuaNumber # 
Num LuaNumber # 
Ord LuaNumber # 
Real LuaNumber # 
RealFloat LuaNumber # 
RealFrac LuaNumber # 
Show LuaNumber # 
FromLuaStack LuaNumber # 
ToLuaStack LuaNumber # 

Methods

push :: LuaNumber -> Lua () #

newtype LuaBool #

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 

fromLuaBool :: LuaBool -> Bool #

Convert a LuaBool to a Haskell Bool.

toLuaBool :: Bool -> LuaBool #

Convert a Haskell Bool to a LuaBool.

Type of Lua values

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 LuaNumber

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 # 
Enum Type # 

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 # 

Methods

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

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

Ord Type # 

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 # 

Methods

showsPrec :: Int -> Type -> ShowS #

show :: Type -> String #

showList :: [Type] -> ShowS #

newtype TypeCode #

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

Constructors

TypeCode 

Fields

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.

Relational Operator

fromRelationalOperator :: RelationalOperator -> CInt #

Convert relation operator to its C representation.

Status

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.

ErrGcmm

error while running a __gc metamethod.

ErrFile

opening or reading a file failed.

Instances

Eq Status # 

Methods

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

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

Show Status # 

toStatus :: StatusCode -> Status #

Convert C integer constant to LuaStatus.

newtype StatusCode #

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

Constructors

StatusCode CInt 

type Failable a = CInt #

Value or an error, using the convention that value below zero indicate an error. Values greater than zero are used verbatim. The phantom type is currently used for documentation only and has no effect.

Gargabe Collection Control

nthFromTop :: CInt -> StackIndex #

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

nthFromBottom :: CInt -> StackIndex #

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

stackTop :: StackIndex #

Top of the stack

stackBottom :: StackIndex #

Bottom of the stack

newtype NumArgs #

The number of arguments expected a function.

Constructors

NumArgs 

Fields