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 * Return an approximation of the kind of the type given all the constructors
76 :: Kind = KStar | (KArrow) infixr 1 Kind Kind
77 genTypeKind :: [GenType] -> Kind
78 instance toString Kind
81 * Predicate whether the outer type is a builtin type
83 class isBuiltin a :: a -> Bool
84 instance isBuiltin Type, GType
87 * Predicate whether the outer type is a basic type
88 * Int, Bool, Char, Real, World, File, Dynamic
90 class isBasic a :: a -> Bool
91 instance isBasic Type, GType
94 * Replace builtin constructors with their pretty names
96 class replaceBuiltins a :: a -> a
97 instance replaceBuiltins Type, GType, GenType
100 * Creates a deep representation of the type
102 generic gType a :: Box GType a
103 derive gType UNIT, EITHER, PAIR, CONS of gcd, FIELD of gfd, OBJECT of gtd, RECORD of grd
104 derive gType Int, Bool, Real, Char, World, File
106 derive gType ?#, ?, ?^
107 derive gType [], [! ], [ !], [!!], [#], [#!], {}, {!}, {#}, {32#}
108 derive gType (), (,), (,,), (,,,), (,,,,), (,,,,,), (,,,,,,), (,,,,,,,)