on f7fc888 help sign in
44 lines 1.8 kB history raw
1module ProjectM36.DataTypes.Primitive where
2import ProjectM36.Base
4primitiveTypeConstructorMapping :: TypeConstructorMapping
5primitiveTypeConstructorMapping = map (\(name, aType) ->
6 (PrimitiveTypeConstructorDef name aType, [])) prims
7 where
8 prims = [("Integer", IntegerAtomType),
9 ("Int", IntAtomType),
10 ("Text", TextAtomType),
11 ("Double", DoubleAtomType),
12 ("Bool", BoolAtomType),
13 ("ByteString", ByteStringAtomType),
14 ("DateTime", DateTimeAtomType),
15 ("Day", DayAtomType)
16 ]
18intTypeConstructor :: TypeConstructor
19intTypeConstructor = PrimitiveTypeConstructor "Int" IntAtomType
21doubleTypeConstructor :: TypeConstructor
22doubleTypeConstructor = PrimitiveTypeConstructor "Double" DoubleAtomType
24textTypeConstructor :: TypeConstructor
25textTypeConstructor = PrimitiveTypeConstructor "Text" TextAtomType
27dayTypeConstructor :: TypeConstructor
28dayTypeConstructor = PrimitiveTypeConstructor "Day" DayAtomType
30dateTimeTypeConstructor :: TypeConstructor
31dateTimeTypeConstructor = PrimitiveTypeConstructor "DateTime" DayAtomType
33-- | Return the type of an 'Atom'.
34atomTypeForAtom :: Atom -> AtomType
35atomTypeForAtom (IntAtom _) = IntAtomType
36atomTypeForAtom (IntegerAtom _) = IntegerAtomType
37atomTypeForAtom (DoubleAtom _) = DoubleAtomType
38atomTypeForAtom (TextAtom _) = TextAtomType
39atomTypeForAtom (DayAtom _) = DayAtomType
40atomTypeForAtom (DateTimeAtom _) = DateTimeAtomType
41atomTypeForAtom (ByteStringAtom _) = ByteStringAtomType
42atomTypeForAtom (BoolAtom _) = BoolAtomType
43atomTypeForAtom (RelationAtom (Relation attrs _)) = RelationAtomType attrs
44atomTypeForAtom (ConstructedAtom _ aType _) = aType