etamoo

Safe HaskellNone
LanguageHaskell2010

MOO.Types

Contents

Description

Basic data types used throughout the MOO server code

Synopsis

Haskell Types Representing MOO Values

type IntT Source

Arguments

 = Int32

MOO integer

type FltT Source

Arguments

 = Double

MOO floating-point number

type StrT Source

Arguments

 = MOOString

MOO string

type ObjT Source

Arguments

 = ObjId

MOO object number

type ErrT Source

Arguments

 = Error

MOO error

type LstT Source

Arguments

 = MOOList

MOO list

type ObjId Source

Arguments

 = Int

MOO object number

data Id Source

MOO identifier (string lite)

type LineNo Source

Arguments

 = Int

MOO code line number

MOO Type and Value Reification

data Type Source

A Type represents one or more MOO value types.

Constructors

TAny

any type

TNum

integer or floating-point number

TInt

integer

TFlt

floating-point number

TStr

string

TObj

object number

TErr

error

TLst

list

Instances

data Value Source

A Value represents any MOO value.

Constructors

Int IntT

integer

Flt FltT

floating-point number

Str StrT

string

Obj ObjT

object number

Err ErrT

error

Lst LstT

list

data Error Source

A MOO error

Constructors

E_NONE

No error

E_TYPE

Type mismatch

E_DIV

Division by zero

E_PERM

Permission denied

E_PROPNF

Property not found

E_VERBNF

Verb not found

E_VARNF

Variable not found

E_INVIND

Invalid indirection

E_RECMOVE

Recursive move

E_MAXREC

Too many verb calls

E_RANGE

Range error

E_ARGS

Incorrect number of arguments

E_NACC

Move refused by destination

E_INVARG

Invalid argument

E_QUOTA

Resource limit exceeded

E_FLOAT

Floating-point arithmetic error

zero :: Value Source

A default MOO value

emptyString :: Value Source

An empty MOO string

emptyList :: Value Source

An empty MOO list

Type and Value Functions

fromId :: Ident a => Id -> a Source

toId :: Ident a => a -> Id Source

builder2text :: Builder -> Text Source

equal :: Value -> Value -> Bool Source

Test two MOO values for indistinguishable (case-sensitive) equality.

comparable :: Value -> Value -> Bool Source

Can the provided values be compared for relative ordering?

truthOf :: Value -> Bool Source

Is the given MOO value considered to be true or false?

truthValue :: Bool -> Value Source

Return a default MOO value (integer) having the given boolean value.

typeOf :: Value -> Type Source

Return a Type indicating the type of the given MOO value.

typeCode :: Type -> IntT Source

Return an integer code corresponding to the given type. These codes are visible to MOO code via the typeof() built-in function and various predefined variables.

intValue :: Value -> Maybe IntT Source

Extract an IntT from a MOO value.

fltValue :: Value -> Maybe FltT Source

Extract a FltT from a MOO value.

strValue :: Value -> Maybe StrT Source

Extract a StrT from a MOO value.

objValue :: Value -> Maybe ObjT Source

Extract an ObjT from a MOO value.

errValue :: Value -> Maybe ErrT Source

Extract an ErrT from a MOO value.

lstValue :: Value -> Maybe LstT Source

Extract a LstT from a MOO value.

toText :: Value -> Text Source

Return a Text representation of the given MOO value, using the same rules as the tostr() built-in function.

toBuilder :: Value -> Builder Source

Return a Builder representation of the given MOO value, using the same rules as the tostr() built-in function.

toBuilder' :: Value -> Builder Source

Return a Builder representation of the given MOO value, using the same rules as the toliteral() built-in function.

toLiteral :: Value -> Text Source

Return a Text representation of the given MOO value, using the same rules as the toliteral() built-in function.

toMicroseconds :: Value -> Maybe Integer Source

Interpret a MOO value as a number of microseconds.

error2text :: Error -> Text Source

Return a string description of the given error value.

List Convenience Functions

fromList :: [Value] -> Value Source

Turn a Haskell list into a MOO list.

fromListBy :: (a -> Value) -> [a] -> Value Source

Turn a Haskell list into a MOO list, using a function to map Haskell values to MOO values.

stringList :: [StrT] -> Value Source

Turn a list of strings into a MOO list.

objectList :: [ObjT] -> Value Source

Turn a list of object numbers into a MOO list.

Miscellaneous

endOfTime :: UTCTime Source

This is the last UTC time value representable as a signed 32-bit seconds-since-1970 value. Unfortunately it is used as a sentinel value in LambdaMOO to represent the starting time of indefinitely suspended tasks, so we really can't support time values beyond this point... yet.

Estimating Haskell Storage Sizes

class Sizeable t where Source

The Sizeable class is used to estimate the storage requirements of various values, for use by several built-in functions which are supposed to return the byte sizes of certain internal structures.

The sizes calculated by instances of this class are necessarily approximate, since it may be difficult or impossible to measure them precisely in the Haskell runtime environment.

Methods

storageBytes :: t -> Int Source

Return the estimated storage size of the given value, in bytes.