1 definition module Data.GenType
4 from StdOverloaded import class ==, class toString
10 reBox x :== box (unBox x)
15 | GTyArrow GType GType
16 | GTyArray ArrayType GType
17 | GTyUList UListType GType
20 | GTyEither GType GType
22 | GTyCons GenericConsDescriptor GType
23 | GTyField GenericFieldDescriptor GType
24 | GTyObject GenericTypeDefDescriptor GType
25 | GTyRecord GenericRecordDescriptor GType
31 | TyArray ArrayType Type
32 | TyUList UListType Type
34 | TyNewType GenericTypeDefDescriptor GenericConsDescriptor Type
35 | TyObject GenericTypeDefDescriptor [(GenericConsDescriptor, [Type])]
36 | TyRecord GenericRecordDescriptor [(GenericFieldDescriptor, Type)]
38 :: BasicType = BTInt | BTChar | BTReal | BTBool | BTDynamic | BTFile | BTWorld
39 :: ArrayType = AStrict | ALazy | AUnboxed | APacked
40 :: UListType = ULLazy | ULStrict
42 instance == GType, Type, BasicType, ArrayType, UListType, GenType
43 instance toString GType, Type, BasicType, ArrayType, UListType, GenType
46 * Removes recursive types by replacing them with references
49 * @result the main type
50 * @result all the separate types grouped in the strongly connected components
52 flattenGType :: GType -> [[GType]]
55 * Convert a GType to a Type. This always returns a Just if the GType was
56 * constructed using the gType generic function
59 * @result a type on success
61 gTypeToType :: GType -> Type
64 * Gives the name for the type
66 typeName :: Type -> String
69 * Gives the genType for a type
71 typeGenType :: Type -> GenType
74 * Predicate whether the outer type is a builtin type
76 class isBuiltin a :: a -> Bool
77 instance isBuiltin Type, GType
80 * Predicate whether the outer type is a basic type
81 * Int, Bool, Char, Real, World, File, Dynamic
83 class isBasic a :: a -> Bool
84 instance isBasic Type, GType
87 * Replace builtin constructors with their pretty names
89 class replaceBuiltins a :: a -> a
90 instance replaceBuiltins Type, GType, GenType
93 * Creates a deep representation of the type
95 generic gType a :: Box GType a
96 derive gType UNIT, EITHER, PAIR, CONS of gcd, FIELD of gfd, OBJECT of gtd, RECORD of grd
97 derive gType Int, Bool, Real, Char, World, File
99 derive gType ?#, ?, ?^
100 derive gType [], [! ], [ !], [!!], [#], [#!], {}, {!}, {#}, {32#}
101 derive gType (), (,), (,,), (,,,), (,,,,), (,,,,,), (,,,,,,), (,,,,,,,)