1 definition module Data.GenType
4 from StdMaybe import :: Maybe
10 reBox x :== box (unBox x)
15 | GTyArrow GType GType
16 | GTyArray ArrayType GType
17 | GTyUList UListType GType
19 | GTyEither GType GType
21 | GTyCons GenericConsDescriptor GType
22 | GTyField GenericFieldDescriptor GType
23 | GTyObject GenericTypeDefDescriptor GType
24 | GTyRecord GenericRecordDescriptor GType
30 | TyArray ArrayType Type
31 | TyUList UListType Type
32 | TyNewType GenericTypeDefDescriptor GenericConsDescriptor Type
33 | TyObject GenericTypeDefDescriptor [(GenericConsDescriptor, [Type])]
34 | TyRecord GenericRecordDescriptor [(GenericFieldDescriptor, Type)]
36 :: BasicType = BTInt | BTChar | BTReal | BTBool | BTDynamic | BTFile | BTWorld
37 :: ArrayType = AStrict | ALazy | AUnboxed | APacked
38 :: UListType = ULLazy | ULStrict
40 instance == GType, Type, BasicType, ArrayType, UListType, GenType
41 instance toString GType, Type, BasicType, ArrayType, UListType, GenType
44 * Removes recursive types by replacing them with references
47 * @result the main type
48 * @result all the separate types grouped in the strongly connected components
50 flattenGType :: GType -> [[GType]]
53 * Convert a GType to a Type. This always returns a Just if the GType was
54 * constructed using the gType generic function
57 * @result a type on success
59 gTypeToType :: GType -> Type
62 * Gives the name for the type
64 typeName :: Type -> String
67 * Predicate whether the outer type is a builtin type
69 class isBuiltin a :: a -> Bool
70 instance isBuiltin Type, GType
73 * Predicate whether the outer type is a basic type
74 * Int, Bool, Char, Real, World, File, Dynamic
76 class isBasic a :: a -> Bool
77 instance isBasic Type, GType
80 * Replace builtin constructors with their pretty names
82 class replaceBuiltins a :: a -> a
83 instance replaceBuiltins Type, GType, GenType
86 * Creates a deep representation of the type
88 generic gType a :: Box GType a
89 derive gType UNIT, EITHER, PAIR, CONS of gcd, FIELD of gfd, OBJECT of gtd, RECORD of grd
90 derive gType Int, Bool, Real, Char, World, Dynamic, File
92 derive gType /*?#,*/ ?, ?^
93 derive gType [], [! ], [ !], [!!], [#], [#!], {}, {!}, {#}, {32#}
94 derive gType (), (,), (,,), (,,,), (,,,,), (,,,,,), (,,,,,,), (,,,,,,,)