hslua-typing-0.2.0: Type specifiers for Lua.
Copyright© 2023-2026 Albert Krewinkel
LicenseMIT
MaintainerAlbert Krewinkel <tarleb@hslua.org>
Safe HaskellNone
LanguageHaskell2010

HsLua.Typing

Description

The module provides Haskell types and values that can be used to describe and declare the types of Lua values.

Synopsis

Documentation

data TypeSpec Source #

Type specification for Lua values.

Constructors

BasicType Type

Built-in type

NamedType Name

A type that's been given a name.

SeqType TypeSpec

Sequence of the given type.

SumType [TypeSpec]

Union type; a sum type.

RecType (Map Name TypeSpec)

Record type (type product).

FunType [TypeSpec] [TypeSpec]

Function type.

AnyType

Unconstrained type.

Instances

Instances details
IsString TypeSpec Source #

For backwards compatibility and convenience, strings can be used as TypeSpec values.

Instance details

Defined in HsLua.Typing

Generic TypeSpec Source # 
Instance details

Defined in HsLua.Typing

Show TypeSpec Source # 
Instance details

Defined in HsLua.Typing

Eq TypeSpec Source # 
Instance details

Defined in HsLua.Typing

Ord TypeSpec Source # 
Instance details

Defined in HsLua.Typing

type Rep TypeSpec Source # 
Instance details

Defined in HsLua.Typing

(#|#) :: TypeSpec -> TypeSpec -> TypeSpec Source #

Returns the sum of two type specifiers, declaring that a Lua value can have either type.

typeSpecToString :: TypeSpec -> String Source #

Generate a string representation of the type specifier.

typeSpecFromString :: String -> TypeSpec Source #

Creates a TypeSpec value from a string.

The implementation currently handles basic types, sequences, and alternatives. A string that cannot be parsed is returned as a Named type with the full string as the name.

Types

anyType :: TypeSpec Source #

Unconstraint type; any Lua value.

voidType :: TypeSpec Source #

A type for which there cannot be any value.

Built-in types

booleanType :: TypeSpec Source #

The built-in boolean Lua type.

functionType :: TypeSpec Source #

The built-in function Lua type.

integerType :: TypeSpec Source #

A Lua integer type.

lightUserdataType :: TypeSpec Source #

The built-in light userdata Lua type.

nilType :: TypeSpec Source #

The built-in nil Lua type.

numberType :: TypeSpec Source #

The built-in number Lua type.

stringType :: TypeSpec Source #

The built-in string Lua type.

tableType :: TypeSpec Source #

The built-in table Lua type.

threadType :: TypeSpec Source #

The built-in thread Lua type.

userdataType :: TypeSpec Source #

The built-in userdata Lua type.

Type constructors

recType :: [(Name, TypeSpec)] -> TypeSpec Source #

Creates a record type.

seqType :: TypeSpec -> TypeSpec Source #

Creates a sequence type.

Marshalling

pushTypeSpec :: LuaError e => TypeSpec -> LuaE e () Source #

Pushes a table representation of a TypeSpec to the stack.

peekTypeSpec :: LuaError e => Peeker e TypeSpec Source #

Retrieves a TypeSpec from a table on the stack.