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 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 ()) 
Instances
Eq LuaState Source # 
Instance details

Defined in Foreign.Lua.Api.Types

FromLuaStack CFunction Source # 
Instance details

Defined in Foreign.Lua.Types.FromLuaStack

FromLuaStack LuaState Source # 
Instance details

Defined in Foreign.Lua.Types.FromLuaStack

ToLuaStack CFunction Source # 
Instance details

Defined in Foreign.Lua.Types.ToLuaStack

Methods

push :: CFunction -> Lua () Source #

MonadReader LuaState Lua # 
Instance details

Defined in Foreign.Lua.Types.Lua

Methods

ask :: Lua LuaState #

local :: (LuaState -> LuaState) -> Lua a -> Lua a #

reader :: (LuaState -> a) -> Lua a #

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 # 
Instance details

Defined in Foreign.Lua.Api.Types

Eq LuaInteger Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Integral LuaInteger Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Num LuaInteger Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Ord LuaInteger Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Real LuaInteger Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Show LuaInteger Source # 
Instance details

Defined in Foreign.Lua.Api.Types

FromLuaStack LuaInteger Source # 
Instance details

Defined in Foreign.Lua.Types.FromLuaStack

ToLuaStack LuaInteger Source # 
Instance details

Defined in Foreign.Lua.Types.ToLuaStack

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 # 
Instance details

Defined in Foreign.Lua.Api.Types

Floating LuaNumber Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Fractional LuaNumber Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Num LuaNumber Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Ord LuaNumber Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Real LuaNumber Source # 
Instance details

Defined in Foreign.Lua.Api.Types

RealFloat LuaNumber Source # 
Instance details

Defined in Foreign.Lua.Api.Types

RealFrac LuaNumber Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Show LuaNumber Source # 
Instance details

Defined in Foreign.Lua.Api.Types

FromLuaStack LuaNumber Source # 
Instance details

Defined in Foreign.Lua.Types.FromLuaStack

ToLuaStack LuaNumber Source # 
Instance details

Defined in Foreign.Lua.Types.ToLuaStack

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

Defined in Foreign.Lua.Api.Types

Methods

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

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

Storable LuaBool Source # 
Instance details

Defined in Foreign.Lua.Api.Types

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 # 
Instance details

Defined in Foreign.Lua.Api.Types

Enum Type Source # 
Instance details

Defined in Foreign.Lua.Api.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.Api.Types

Methods

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

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

Ord Type Source # 
Instance details

Defined in Foreign.Lua.Api.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.Api.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.Api.Types

Ord TypeCode Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Show TypeCode Source # 
Instance details

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

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

Defined in Foreign.Lua.Api.Types

Methods

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

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

Show Status Source # 
Instance details

Defined in Foreign.Lua.Api.Types

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

Defined in Foreign.Lua.Api.Types

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

newtype StackIndex Source #

A stack index

Constructors

StackIndex 

Fields

Instances
Enum StackIndex Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Eq StackIndex Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Num StackIndex Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Ord StackIndex Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Show StackIndex Source # 
Instance details

Defined in Foreign.Lua.Api.Types

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

Instances
Eq NumArgs Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Methods

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

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

Num NumArgs Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Ord NumArgs Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Show NumArgs Source # 
Instance details

Defined in Foreign.Lua.Api.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.Api.Types

Num NumResults Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Ord NumResults Source # 
Instance details

Defined in Foreign.Lua.Api.Types

Show NumResults Source # 
Instance details

Defined in Foreign.Lua.Api.Types

FromLuaStack CFunction Source # 
Instance details

Defined in Foreign.Lua.Types.FromLuaStack

ToLuaStack CFunction Source # 
Instance details

Defined in Foreign.Lua.Types.ToLuaStack

Methods

push :: CFunction -> Lua () Source #

ToHaskellFunction HaskellFunction Source # 
Instance details

Defined in Foreign.Lua.FunctionCalling