on fbfa2ea help sign in
38 lines 1.5 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 = [("Int", IntAtomType),
9 ("Text", TextAtomType),
10 ("Double", DoubleAtomType),
11 ("Bool", BoolAtomType),
12 ("ByteString", ByteStringAtomType)
13 ]
15intTypeConstructor :: TypeConstructor
16intTypeConstructor = PrimitiveTypeConstructor "Int" IntAtomType
18doubleTypeConstructor :: TypeConstructor
19doubleTypeConstructor = PrimitiveTypeConstructor "Double" DoubleAtomType
21textTypeConstructor :: TypeConstructor
22textTypeConstructor = PrimitiveTypeConstructor "Text" TextAtomType
24dayTypeConstructor :: TypeConstructor
25dayTypeConstructor = PrimitiveTypeConstructor "Day" DayAtomType
27-- | Return the type of an 'Atom'.
28atomTypeForAtom :: Atom -> AtomType
29atomTypeForAtom (IntAtom _) = IntAtomType
30atomTypeForAtom (DoubleAtom _) = DoubleAtomType
31atomTypeForAtom (TextAtom _) = TextAtomType
32atomTypeForAtom (DayAtom _) = DayAtomType
33atomTypeForAtom (DateTimeAtom _) = DateTimeAtomType
34atomTypeForAtom (ByteStringAtom _) = ByteStringAtomType
35atomTypeForAtom (BoolAtom _) = BoolAtomType
36atomTypeForAtom (IntervalAtom a _ _ _) = IntervalAtomType (atomTypeForAtom a)
37atomTypeForAtom (RelationAtom (Relation attrs _)) = RelationAtomType attrs
38atomTypeForAtom (ConstructedAtom _ aType _) = aType