hslua-0.9.5.1: 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 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

LuaState (Ptr ()) 

type CFunction = FunPtr (LuaState -> 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 LuaInteger 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

LuaInteger Int64 

Instances

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

Methods

push :: LuaInteger -> Lua () Source #

newtype LuaNumber 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

LuaNumber Double 

Instances

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

Methods

push :: LuaNumber -> Lua () Source #

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 

fromLuaBool :: LuaBool -> Bool Source #

Convert a LuaBool to a Haskell Bool.

toLuaBool :: Bool -> LuaBool Source #

Convert a Haskell Bool to a LuaBool.

Type of Lua values

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

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 # 

Methods

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

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

Ord Type Source # 

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 # 

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

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.

Relational Operator

fromRelationalOperator :: RelationalOperator -> CInt Source #

Convert relation operator to its C representation.

Status

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

toStatus :: StatusCode -> Status Source #

Convert C integer constant to LuaStatus.

newtype StatusCode Source #

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

Constructors

StatusCode CInt 

type Failable a = CInt Source #

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

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

nthFromBottom :: CInt -> StackIndex Source #

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

stackTop :: StackIndex Source #

Top of the stack

stackBottom :: StackIndex Source #

Bottom of the stack

newtype NumArgs Source #

The number of arguments expected a function.

Constructors

NumArgs 

Fields