@@ -2,6 +2,7 @@
22import ProjectM36.Client
33import ProjectM36.TupleSet
44import ProjectM36.Atom
5+import ProjectM36.DataTypes.Primitive
56import ProjectM36.Base
67import ProjectM36.Relation.Show.Term
78
@@ -20,16 +21,19 @@ main = do
2021 Left err -> putStrLn (show err)
2122 Right sessionId -> do
2223 --4. define a new relation variable with a DatabaseContext expression
23− let attrs = attributesFromList [Attribute "name" stringAtomType, Attribute "age" intAtomType]
24− mErr1 <- executeDatabaseContextExpr sessionId conn (Define "person" attrs)
24+ let attrExprs = [AttributeAndTypeNameExpr "name" (PrimitiveTypeConstructor "Text" textAtomType),
25+ AttributeAndTypeNameExpr "age" (PrimitiveTypeConstructor "Int" intAtomType)]
26+ attrs = attributesFromList [Attribute "name" textAtomType,
27+ Attribute "age" intAtomType]
28+ mErr1 <- executeDatabaseContextExpr sessionId conn (Define "person" attrExprs)
2529 putStrLn (show mErr1)
2630 --5. add a tuple to the relation referenced by the relation variable
27− let (Right tupSet) = mkTupleSetFromList attrs [[stringAtom "Bob", intAtom 45]]
31+ let (Right tupSet) = mkTupleSetFromList attrs [[textAtom "Bob", intAtom 45]]
2832 mErr2 <- executeDatabaseContextExpr sessionId conn (Insert "person" (MakeStaticRelation attrs tupSet))
2933 putStrLn (show mErr2)
3034
3135 --6. execute a relational algebra query
32− let restrictionPredicate = AttributeEqualityPredicate "name" (NakedAtomExpr (stringAtom "Steve"))
36+ let restrictionPredicate = AttributeEqualityPredicate "name" (NakedAtomExpr (textAtom "Steve"))
3337 eRel <- executeRelationalExpr sessionId conn (Restrict restrictionPredicate (RelationVariable "person"))
3438 case eRel of
3539 Left err -> putStrLn (show err)