sutori-0.2.4: Sutori language compiler

Safe HaskellSafe
LanguageHaskell2010

Sutori.Types

Description

TODO: Sort and document API

Synopsis

Documentation

type SutTypeID = Int Source #

A type will be represented by an ID

data SutType Source #

Sutori type constructors

Constructors

SutPrimitiveType SutPrimitive

A Primitive Type

SutDirection SutTypeID

A Direction (Pointer) to a value of some type

SutChain Int SutTypeID

A Chain (Array) of fixed size of element type

SutMachine [(SutID, SutTypeID)]

A Machine (Struct) of different components

SutThing [(SutID, SutTypeID)]

A Thing (Union) that might have different names

primitiveType :: SutType -> SutPrimitive Source #

Extract the primitive from the type definition

generalizeTypes :: SutType -> SutType -> SutType Source #

Generalize two types to their LCA, if any

primitiveError :: SutType Source #

Constant primitive error type

data TypeGraph Source #

The type graph must be a biderectional map (as there's a bijection between type and its ID)

initialTypeGraph :: TypeGraph Source #

The initial value for the graph. That is, the primitives added

initialNextTypeID :: Int Source #

The initial value for the "next type ID"

insertType :: (SutType, SutTypeID) -> TypeGraph -> TypeGraph Source #

Inserts a type mapping into the map

lookupTypeID :: SutType -> TypeGraph -> Maybe (SutTypeID, Int) Source #

Maybe the SutTypeID of the given type

lookupType :: SutTypeID -> TypeGraph -> Maybe (SutType, Int) Source #

Maybe the type of the given SutTypeID

orderedGraph :: TypeGraph -> [(SutTypeID, (SutType, Int))] Source #

The graph as a list sorted by ID (first appearance?)

primitives :: [SutPrimitive] Source #

Predefined Sutori types to initialize symtable

primitiveID :: SutPrimitive -> SutTypeID Source #

Eventual TypeIDs for the type graph

primitiveIDs :: [(SutPrimitive, SutTypeID)] Source #

Zipped primitives with their IDs

generalizePrimitives :: SutPrimitive -> SutPrimitive -> SutPrimitive Source #

Given two types, this is the most general one (LCA) Right now LCA is just always one of them

toTypeLight :: SutPrimitive -> SutPrimitive Source #

Convert primitive to boolean type

toTypeNum :: SutPrimitive -> SutPrimitive Source #

Convert primitive to the most specific numerical type available

toTypeBag :: SutPrimitive -> SutPrimitive Source #

Convert primitive to the most specific numerical type available

toTypeWallet :: SutPrimitive -> SutPrimitive Source #

Convert primitive to the general float type

toTypePhrase :: SutPrimitive -> SutPrimitive Source #

Convert primitive to the most general string (printable) type

toTypeSortable :: SutPrimitive -> SutPrimitive Source #

Convert primitive to a sortable type or error

toTypeEq :: SutPrimitive -> SutPrimitive Source #

Convert primitive to a equalable type or error

memberOffset :: SutType -> String -> Int Source #

Lookup and check a machine/thing member's offset