| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Sutori.Types
Description
TODO: Sort and document API
- type SutTypeID = Int
- data SutType
- primitiveType :: SutType -> SutPrimitive
- generalizeTypes :: SutType -> SutType -> SutType
- primitiveError :: SutType
- data TypeGraph = TypeGraph (Map SutType (SutTypeID, Int)) (Map SutTypeID (SutType, Int))
- initialTypeGraph :: TypeGraph
- initialNextTypeID :: Int
- insertType :: (SutType, SutTypeID) -> TypeGraph -> TypeGraph
- lookupTypeID :: SutType -> TypeGraph -> Maybe (SutTypeID, Int)
- lookupType :: SutTypeID -> TypeGraph -> Maybe (SutType, Int)
- orderedGraph :: TypeGraph -> [(SutTypeID, (SutType, Int))]
- data SutPrimitive
- primitives :: [SutPrimitive]
- primitiveID :: SutPrimitive -> SutTypeID
- primitiveIDs :: [(SutPrimitive, SutTypeID)]
- generalizePrimitives :: SutPrimitive -> SutPrimitive -> SutPrimitive
- toTypeLight :: SutPrimitive -> SutPrimitive
- toTypeNum :: SutPrimitive -> SutPrimitive
- toTypeBag :: SutPrimitive -> SutPrimitive
- toTypeWallet :: SutPrimitive -> SutPrimitive
- toTypePhrase :: SutPrimitive -> SutPrimitive
- toTypeSortable :: SutPrimitive -> SutPrimitive
- toTypeEq :: SutPrimitive -> SutPrimitive
- memberOffset :: SutType -> String -> Int
Documentation
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
primitiveError :: SutType Source #
Constant primitive error type
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?)
data SutPrimitive Source #
Sutori primitives
Constructors
| SutBag | A bag (Int) |
| SutWallet | A wallet (Float) |
| SutPhrase | A phrase (String) |
| SutLight | A light (Bool) |
| SutLetter | A letter (Char) |
| SutTypeVoid | A void element (Void) |
| SutTypeError | A Type Error (&^%$#) |
Instances
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