| Copyright | © 2020-2021 Albert Krewinkel |
|---|---|
| License | MIT |
| Maintainer | Albert Krewinkel <tarleb+hslua@zeitkraut.de> |
| Safe Haskell | None |
| Language | Haskell2010 |
HsLua.Packaging.UDType
Contents
Description
This module provides types and functions to use Haskell values as userdata objects in Lua. These objects wrap a Haskell value and provide methods and properties to interact with the Haskell value.
The terminology in this module refers to the userdata values as /UD objects, and to their type as UD type/.
Synopsis
- type DocumentedType e a = UDType e (DocumentedFunction e) a
- type DocumentedTypeWithList e a itemtype = UDTypeWithList e (DocumentedFunction e) a itemtype
- deftype :: LuaError e => Name -> [(Operation, DocumentedFunction e)] -> [Member e (DocumentedFunction e) a] -> DocumentedType e a
- deftype' :: LuaError e => Name -> [(Operation, DocumentedFunction e)] -> [Member e (DocumentedFunction e) a] -> Maybe (ListSpec e a itemtype) -> DocumentedTypeWithList e a itemtype
- method :: DocumentedFunction e -> Member e (DocumentedFunction e) a
- property :: LuaError e => Name -> Text -> (Pusher e b, a -> b) -> (Peeker e b, a -> b -> a) -> Member e fn a
- possibleProperty :: LuaError e => Name -> Text -> (Pusher e b, a -> Possible b) -> (Peeker e b, a -> b -> Possible a) -> Member e fn a
- readonly :: Name -> Text -> (Pusher e b, a -> b) -> Member e fn a
- alias :: Name -> Text -> [AliasIndex] -> Member e fn a
- operation :: Operation -> DocumentedFunction e -> (Operation, DocumentedFunction e)
- peekUD :: LuaError e => UDTypeWithList e fn a itemtype -> Peeker e a
- pushUD :: LuaError e => UDTypeWithList e fn a itemtype -> a -> LuaE e ()
- udparam :: LuaError e => DocumentedTypeWithList e a itemtype -> Text -> Text -> Parameter e a
- data Member e fn a
- data Operation
- data Property e a
- data Possible a
Documentation
type DocumentedType e a = UDType e (DocumentedFunction e) a Source #
Type definitions containing documented functions.
type DocumentedTypeWithList e a itemtype = UDTypeWithList e (DocumentedFunction e) a itemtype Source #
A userdata type, capturing the behavior of Lua objects that wrap Haskell values. The type name must be unique; once the type has been used to push or retrieve a value, the behavior can no longer be modified through this type.
Arguments
| :: LuaError e | |
| => Name | type name |
| -> [(Operation, DocumentedFunction e)] | operations |
| -> [Member e (DocumentedFunction e) a] | methods |
| -> DocumentedType e a |
Defines a new type, defining the behavior of objects in Lua. Note that the type name must be unique.
Arguments
| :: LuaError e | |
| => Name | type name |
| -> [(Operation, DocumentedFunction e)] | operations |
| -> [Member e (DocumentedFunction e) a] | methods |
| -> Maybe (ListSpec e a itemtype) | list access |
| -> DocumentedTypeWithList e a itemtype |
Defines a new type that could also be treated as a list; defines the behavior of objects in Lua. Note that the type name must be unique.
method :: DocumentedFunction e -> Member e (DocumentedFunction e) a Source #
Use a documented function as an object method.
Arguments
| :: LuaError e | |
| => Name | property name |
| -> Text | property description |
| -> (Pusher e b, a -> b) | how to get the property value |
| -> (Peeker e b, a -> b -> a) | how to set a new property value |
| -> Member e fn a |
Declares a new read- and writable property.
Arguments
| :: LuaError e | |
| => Name | property name |
| -> Text | property description |
| -> (Pusher e b, a -> Possible b) | how to get the property value |
| -> (Peeker e b, a -> b -> Possible a) | how to set a new property value |
| -> Member e fn a |
Declares a new read- and writable property which is not always available.
Arguments
| :: Name | property name |
| -> Text | property description |
| -> (Pusher e b, a -> b) | how to get the property value |
| -> Member e fn a |
Creates a read-only object property. Attempts to set the value will cause an error.
Arguments
| :: Name | property alias |
| -> Text | description |
| -> [AliasIndex] | sequence of nested properties |
| -> Member e fn a |
Define an alias for another, possibly nested, property.
Arguments
| :: Operation | the kind of operation |
| -> DocumentedFunction e | function used to perform the operation |
| -> (Operation, DocumentedFunction e) |
Declares a new object operation from a documented function.
peekUD :: LuaError e => UDTypeWithList e fn a itemtype -> Peeker e a #
Retrieves a userdata value of the given type.
pushUD :: LuaError e => UDTypeWithList e fn a itemtype -> a -> LuaE e () #
Pushes a userdata value of the given type.
Arguments
| :: LuaError e | |
| => DocumentedTypeWithList e a itemtype | expected type |
| -> Text | parameter name |
| -> Text | parameter description |
| -> Parameter e a |
Defines a function parameter that takes the given type.
Helper types for building
Lua metadata operation types.
Constructors
| Add | the addition ( |
| Sub | the subtraction ( |
| Mul | the multiplication ( |
| Div | the division ( |
| Mod | the modulo ( |
| Pow | the exponentiation ( |
| Unm | the negation (unary |
| Idiv | the floor division ( |
| Band | the bitwise AND ( |
| Bor | the bitwise OR ( |
| Bxor | the bitwise exclusive OR (binary |
| Bnot | the bitwise NOT (unary |
| Shl | the bitwise left shift ( |
| Shr | the bitwise right shift ( |
| Concat | the concatenation ( |
| Len | the length ( |
| Eq | the equal ( |
| Lt | the less than ( |
| Le | the less equal ( |
| Index | The indexing access operation |
| Newindex | The indexing assignment |
| Call | The call operation |
| Tostring | The operation used to create a string representation of the object. |
| Pairs | the operation of iterating over the object's key-value pairs. |
| CustomOperation Name | a custom operation, with the metamethod name as parameter. |
Instances
| Eq Operation | |
| Ord Operation | |
Defined in HsLua.ObjectOrientation.Operation | |
| Show Operation | |