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

Defined in Foreign.Lua.Api.Types

FromLuaStack CFunction # 
Instance details

Defined in Foreign.Lua.Types.FromLuaStack

FromLuaStack LuaState # 
Instance details

Defined in Foreign.Lua.Types.FromLuaStack

ToLuaStack CFunction # 
Instance details

Defined in Foreign.Lua.Types.ToLuaStack

Methods

push :: CFunction -> Lua () #

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

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

Defined in Foreign.Lua.Api.Types

Eq LuaInteger # 
Instance details

Defined in Foreign.Lua.Api.Types

Integral LuaInteger # 
Instance details

Defined in Foreign.Lua.Api.Types

Num LuaInteger # 
Instance details

Defined in Foreign.Lua.Api.Types

Ord LuaInteger # 
Instance details

Defined in Foreign.Lua.Api.Types

Real LuaInteger # 
Instance details

Defined in Foreign.Lua.Api.Types

Show LuaInteger # 
Instance details

Defined in Foreign.Lua.Api.Types

FromLuaStack LuaInteger # 
Instance details

Defined in Foreign.Lua.Types.FromLuaStack

ToLuaStack LuaInteger # 
Instance details

Defined in Foreign.Lua.Types.ToLuaStack

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

Defined in Foreign.Lua.Api.Types

Floating LuaNumber # 
Instance details

Defined in Foreign.Lua.Api.Types

Fractional LuaNumber # 
Instance details

Defined in Foreign.Lua.Api.Types

Num LuaNumber # 
Instance details

Defined in Foreign.Lua.Api.Types

Ord LuaNumber # 
Instance details

Defined in Foreign.Lua.Api.Types

Real LuaNumber # 
Instance details

Defined in Foreign.Lua.Api.Types

RealFloat LuaNumber # 
Instance details

Defined in Foreign.Lua.Api.Types

RealFrac LuaNumber # 
Instance details

Defined in Foreign.Lua.Api.Types

Show LuaNumber # 
Instance details

Defined in Foreign.Lua.Api.Types

FromLuaStack LuaNumber # 
Instance details

Defined in Foreign.Lua.Types.FromLuaStack

ToLuaStack LuaNumber # 
Instance details

Defined in Foreign.Lua.Types.ToLuaStack

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

Defined in Foreign.Lua.Api.Types

Methods

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

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

Storable LuaBool # 
Instance details

Defined in Foreign.Lua.Api.Types

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

Defined in Foreign.Lua.Api.Types

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

Defined in Foreign.Lua.Api.Types

Methods

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

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

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

Defined in Foreign.Lua.Api.Types

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

Instances
Eq TypeCode # 
Instance details

Defined in Foreign.Lua.Api.Types

Ord TypeCode # 
Instance details

Defined in Foreign.Lua.Api.Types

Show TypeCode # 
Instance details

Defined in Foreign.Lua.Api.Types

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

data RelationalOperator #

Lua comparison operations.

Constructors

EQ

Correponds to lua's equality (==) operator.

LT

Correponds to lua's strictly-lesser-than (<) operator

LE

Correponds to lua's lesser-or-equal (<=) 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 # 
Instance details

Defined in Foreign.Lua.Api.Types

Methods

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

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

Show Status # 
Instance details

Defined in Foreign.Lua.Api.Types

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

Defined in Foreign.Lua.Api.Types

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

newtype StackIndex #

A stack index

Constructors

StackIndex 

Fields

Instances
Enum StackIndex # 
Instance details

Defined in Foreign.Lua.Api.Types

Eq StackIndex # 
Instance details

Defined in Foreign.Lua.Api.Types

Num StackIndex # 
Instance details

Defined in Foreign.Lua.Api.Types

Ord StackIndex # 
Instance details

Defined in Foreign.Lua.Api.Types

Show StackIndex # 
Instance details

Defined in Foreign.Lua.Api.Types

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

Instances
Eq NumArgs # 
Instance details

Defined in Foreign.Lua.Api.Types

Methods

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

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

Num NumArgs # 
Instance details

Defined in Foreign.Lua.Api.Types

Ord NumArgs # 
Instance details

Defined in Foreign.Lua.Api.Types

Show NumArgs # 
Instance details

Defined in Foreign.Lua.Api.Types

newtype NumResults #

The number of results returned by a function call.

Constructors

NumResults 

Fields