on dc3ee07 help sign in
40 lines 1.6 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 ]
16intTypeConstructor :: TypeConstructor
17intTypeConstructor = PrimitiveTypeConstructor "Int" IntAtomType
19doubleTypeConstructor :: TypeConstructor
20doubleTypeConstructor = PrimitiveTypeConstructor "Double" DoubleAtomType
22textTypeConstructor :: TypeConstructor
23textTypeConstructor = PrimitiveTypeConstructor "Text" TextAtomType
25dayTypeConstructor :: TypeConstructor
26dayTypeConstructor = PrimitiveTypeConstructor "Day" DayAtomType
28-- | Return the type of an 'Atom'.
29atomTypeForAtom :: Atom -> AtomType
30atomTypeForAtom (IntAtom _) = IntAtomType
31atomTypeForAtom (IntegerAtom _) = IntegerAtomType
32atomTypeForAtom (DoubleAtom _) = DoubleAtomType
33atomTypeForAtom (TextAtom _) = TextAtomType
34atomTypeForAtom (DayAtom _) = DayAtomType
35atomTypeForAtom (DateTimeAtom _) = DateTimeAtomType
36atomTypeForAtom (ByteStringAtom _) = ByteStringAtomType
37atomTypeForAtom (BoolAtom _) = BoolAtomType
38atomTypeForAtom (IntervalAtom a _ _ _) = IntervalAtomType (atomTypeForAtom a)
39atomTypeForAtom (RelationAtom (Relation attrs _)) = RelationAtomType attrs
40atomTypeForAtom (ConstructedAtom _ aType _) = aType