on master help sign in
all tests passing now
commit4724158d51a0f3e36854ec2f17dc832ac86e19c5 authorAgentM <agentm@themactionfaction.com> dateSun 20 Mar 2016, 14:27 (11 years ago) parentf0b4bdc
9 files changed+82−87
ProjectM36/DateExamples.hs+19−19 ProjectM36/Transaction/Persist.hs+2−1 ProjectM36/TransactionGraph/Persist.hs−1 TutorialD/Interpreter/RelationalExpr.hs+1−4 scripts/DateExamples.tutd+5−5 test/Relation/StaticOptimizer.hs+11−12 test/TransactionGraph/Persist.hs+1−1 test/TutorialD/Interpreter.hs+41−41 test/TutorialD/Interpreter/Import/TutorialD.hs+2−3
ProjectM36/DateExamples.hs+19−19
@@ -18,16 +18,16 @@ dateExamples = DatabaseContext { inclusionDependencies = dateIncDeps,
1818 notifications = M.empty,
1919 atomFunctions = basicAtomFunctions,
2020 typeConstructorMapping = basicTypeConstructorMapping }
21− where
22− dateRelVars = M.fromList [("S", suppliers),
23− ("P", products),
24− ("SP", supplierProducts)]
21+ where -- these must be lower case now that data constructors are in play
22+ dateRelVars = M.fromList [("s", suppliers),
23+ ("p", products),
24+ ("sp", supplierProducts)]
2525 suppliers = suppliersRel
2626 products = productsRel
2727 supplierProducts = supplierProductsRel
28− dateIncDeps = M.fromList [("S_pkey", simplePKey ["S#"] "S"),
29− ("P_pkey", simplePKey ["P#"] "P"),
30− ("SP_pkey", simplePKey ["S#", "P#"] "SP")
28+ dateIncDeps = M.fromList [("s_pkey", simplePKey ["s#"] "s"),
29+ ("p_pkey", simplePKey ["p#"] "p"),
30+ ("sp_pkey", simplePKey ["s#", "p#"] "sp")
3131 ]
3232 simplePKey attrNames relvarName = inclusionDependencyForKey (AttributeNames $ S.fromList attrNames) (RelationVariable relvarName)
3333
@@ -36,10 +36,10 @@ suppliersRel = case mkRelationFromList attrs atomMatrix of
3636 Left _ -> undefined
3737 Right rel -> rel
3838 where
39− attrs = A.attributesFromList [Attribute "S#" textAtomType,
40− Attribute "SNAME" textAtomType,
41− Attribute "STATUS" intAtomType,
42− Attribute "CITY" textAtomType]
39+ attrs = A.attributesFromList [Attribute "s#" textAtomType,
40+ Attribute "sname" textAtomType,
41+ Attribute "status" intAtomType,
42+ Attribute "city" textAtomType]
4343 atomMatrix = [
4444 [textAtom "S1", textAtom "Smith", intAtom 20, textAtom "London"],
4545 [textAtom "S2", textAtom "Jones", intAtom 10, textAtom "Paris"],
@@ -52,9 +52,9 @@ supplierProductsRel = case mkRelationFromList attrs matrix of
5252 Left _ -> undefined
5353 Right rel -> rel
5454 where
55− attrs = A.attributesFromList [Attribute "S#" textAtomType,
56− Attribute "P#" textAtomType,
57− Attribute "QTY" intAtomType]
55+ attrs = A.attributesFromList [Attribute "s#" textAtomType,
56+ Attribute "p#" textAtomType,
57+ Attribute "qty" intAtomType]
5858 matrix = [
5959 [textAtom "S1", textAtom "P1", intAtom 300],
6060 [textAtom "S1", textAtom "P2", intAtom 200],
@@ -75,11 +75,11 @@ productsRel = case mkRelationFromList attrs matrix of
7575 Left _ -> undefined
7676 Right rel -> rel
7777 where
78− attrs = A.attributesFromList [Attribute "P#" textAtomType,
79− Attribute "PNAME" textAtomType,
80− Attribute "COLOR" textAtomType,
81− Attribute "WEIGHT" intAtomType,
82− Attribute "CITY" textAtomType]
78+ attrs = A.attributesFromList [Attribute "p#" textAtomType,
79+ Attribute "pname" textAtomType,
80+ Attribute "color" textAtomType,
81+ Attribute "weight" intAtomType,
82+ Attribute "city" textAtomType]
8383 matrix = [
8484 [textAtom "P1", textAtom "Nut", textAtom "Red", intAtom 12, textAtom "London"],
8585 [textAtom "P2", textAtom "Bolt", textAtom "Green", intAtom 17, textAtom "Paris"],
ProjectM36/Transaction/Persist.hs+2−1
@@ -139,7 +139,8 @@ readIncDeps transDir = do
139139 return $ M.fromList incDeps
140140
141141writeTypeConstructorMapping :: DiskSync -> FilePath -> TypeConstructorMapping -> IO ()
142−writeTypeConstructorMapping sync path types = writeBSFileSync sync path $ B.encode types
142+writeTypeConstructorMapping sync path types = let atPath = typeConsPath path in
143+ writeBSFileSync sync atPath $ B.encode types
143144
144145readTypeConstructorMapping :: FilePath -> IO (TypeConstructorMapping)
145146readTypeConstructorMapping path = do
ProjectM36/TransactionGraph/Persist.hs−1
@@ -57,7 +57,6 @@ bootstrapDatabaseDir sync dbdir bootstrapGraph = do
5757 transactionGraphPersist sync dbdir bootstrapGraph
5858 putStrLn "Bootstrapped DB."
5959
60−
6160{-
6261incrementally updates an existing database directory
6362--algorithm:
TutorialD/Interpreter/RelationalExpr.hs+1−4
@@ -191,13 +191,10 @@ attributeAtomExprP = do
191191nakedAtomExprP :: Parser AtomExpr
192192nakedAtomExprP = NakedAtomExpr <$> atomP
193193
194−-- | Uses square brackets for TutorialD support.
195194constructedAtomExprP :: Parser AtomExpr
196195constructedAtomExprP = do
197− dConsName <- identifier
198− --_ <- char '['
196+ dConsName <- capitalizedIdentifier
199197 dConsArgs <- sepBy atomExprP spaces
200− --_ <- char ']'
201198 pure $ ConstructedAtomExpr (T.pack dConsName) dConsArgs
202199
203200-- used only for primitive type parsing ?
scripts/DateExamples.tutd+5−5
@@ -1,5 +1,5 @@
1−S := relation{tuple{S# "S1",SNAME "Smith",STATUS 20, CITY "London"}, tuple{S# "S2",SNAME "Jones",STATUS 10,CITY "Paris"}, tuple{S# "S3",SNAME "Blake",STATUS 30,CITY "Paris"}, tuple{S# "S4",SNAME "Clark",STATUS 20,CITY "London"}, tuple{S# "S5",SNAME "Adams",STATUS 30,CITY "Athens"}}
2−P := relation{tuple{P# "P1",PNAME "Nut",COLOR "Red",WEIGHT 12,CITY "London"}, tuple{P# "P2",PNAME "Bolt",COLOR "Green",WEIGHT 17,CITY "Paris"}, tuple{P# "P3",PNAME "Screw",COLOR "Blue",WEIGHT 17,CITY "Oslo"}, tuple{P# "P4",PNAME "Screw",COLOR "Red",WEIGHT 14,CITY "London"}, tuple{P# "P5",PNAME "Cam",COLOR "Blue",WEIGHT 12,CITY "Paris"}, tuple{P# "P6", PNAME "Cog", COLOR "Red",WEIGHT 19,CITY "London"}}
3−SP := relation{tuple{S# "S1",P# "P1",QTY 300}, tuple{S# "S1",P# "P2",QTY 200}, tuple{S# "S1",P# "P3",QTY 400}, tuple{S# "S1",P# "P4",QTY 200}, tuple{S# "S1",P# "P5",QTY 100}, tuple{S# "S1",P# "P6",QTY 100}, tuple{S# "S2",P# "P1",QTY 300}, tuple{S# "S2",P# "P2",QTY 400}, tuple{S# "S3",P# "P2",QTY 200}, tuple{S# "S4",P# "P4",QTY 300}, tuple{S# "S4",P# "P5",QTY 400}}
4−foreign key SP2S SP{S#} in S{S#}
5−foreign key SP2P SP{P#} in P{P#}
1+s := relation{tuple{s# "S1",sname "Smith",status 20, city "London"}, tuple{s# "S2",sname "Jones",status 10,city "Paris"}, tuple{s# "S3",sname "Blake",status 30,city "Paris"}, tuple{s# "S4",sname "Clark",status 20,city "London"}, tuple{s# "S5",sname "Adams",status 30,city "Athens"}}
2+p := relation{tuple{p# "P1",PNAME "Nut",COLOR "Red",WEIGHT 12,city "London"}, tuple{p# "P2",PNAME "Bolt",COLOR "Green",WEIGHT 17,city "Paris"}, tuple{p# "P3",PNAME "Screw",COLOR "Blue",WEIGHT 17,city "Oslo"}, tuple{p# "P4",PNAME "Screw",COLOR "Red",WEIGHT 14,city "London"}, tuple{p# "P5",PNAME "Cam",COLOR "Blue",WEIGHT 12,city "Paris"}, tuple{p# "P6", PNAME "Cog", COLOR "Red",WEIGHT 19,city "London"}}
3+sp := relation{tuple{s# "S1",p# "P1",qty 300}, tuple{s# "S1",p# "P2",qty 200}, tuple{s# "S1",p# "P3",qty 400}, tuple{s# "S1",p# "P4",qty 200}, tuple{s# "S1",p# "P5",qty 100}, tuple{s# "S1",p# "P6",qty 100}, tuple{s# "S2",p# "P1",qty 300}, tuple{s# "S2",p# "P2",qty 400}, tuple{s# "S3",p# "P2",qty 200}, tuple{s# "S4",p# "P4",qty 300}, tuple{s# "S4",p# "P5",qty 400}}
4+foreign key sp2s sp{s#} in s{s#}
5+foreign key sp2p sp{p#} in p{p#}
test/Relation/StaticOptimizer.hs+11−12
@@ -1,7 +1,6 @@
11{-# LANGUAGE OverloadedStrings #-}
22import ProjectM36.Base
33import ProjectM36.Relation
4−import ProjectM36.RelationalExpression
54import ProjectM36.DateExamples
65import ProjectM36.TupleSet
76import ProjectM36.StaticOptimizer
@@ -17,20 +16,20 @@ main = do
1716 tests = relationOptTests ++ databaseOptTests
1817 optTest optfunc testparams = map (\(name, expr, unopt) -> TestCase $ assertEqual name expr (evalState (optfunc unopt) dateExamples)) $ testparams
1918 relationOptTests = optTest applyStaticRelationalOptimization [
20− ("StaticProject", Right $ RelationVariable "S", Project (AttributeNames (attributeNames suppliersRel)) (RelationVariable "S")),
21− ("StaticUnion", Right $ RelationVariable "S", Union (RelationVariable "S") (RelationVariable "S")),
22− ("StaticJoin", Right $ RelationVariable "S", Join (RelationVariable "S") (RelationVariable "S")),
23− ("StaticRestrictTrue", Right $ RelationVariable "S", Restrict TruePredicate (RelationVariable "S")),
24− ("StaticRestrictFalse", Right $ MakeStaticRelation (attributes suppliersRel) emptyTupleSet, Restrict (NotPredicate TruePredicate) (RelationVariable "S"))
19+ ("StaticProject", Right $ RelationVariable "s", Project (AttributeNames (attributeNames suppliersRel)) (RelationVariable "s")),
20+ ("StaticUnion", Right $ RelationVariable "s", Union (RelationVariable "s") (RelationVariable "s")),
21+ ("StaticJoin", Right $ RelationVariable "s", Join (RelationVariable "s") (RelationVariable "s")),
22+ ("StaticRestrictTrue", Right $ RelationVariable "s", Restrict TruePredicate (RelationVariable "s")),
23+ ("StaticRestrictFalse", Right $ MakeStaticRelation (attributes suppliersRel) emptyTupleSet, Restrict (NotPredicate TruePredicate) (RelationVariable "s"))
2524 ]
2625 databaseOptTests = optTest applyStaticDatabaseOptimization [
2726 ("StaticAssign",
28− Right $ Assign "z" (RelationVariable "S"),
29− Assign "z" (Restrict TruePredicate (RelationVariable "S"))
27+ Right $ Assign "z" (RelationVariable "s"),
28+ Assign "z" (Restrict TruePredicate (RelationVariable "s"))
3029 ),
3130 ("StaticMultipleExpr",
32− Right $ MultipleExpr [Assign "z" (RelationVariable "S"),
33− Assign "z" (RelationVariable "S")],
34− MultipleExpr [Assign "z" (Restrict TruePredicate (RelationVariable "S")),
35− Assign "z" (Restrict TruePredicate (RelationVariable "S"))])
31+ Right $ MultipleExpr [Assign "z" (RelationVariable "s"),
32+ Assign "z" (RelationVariable "s")],
33+ MultipleExpr [Assign "z" (Restrict TruePredicate (RelationVariable "s")),
34+ Assign "z" (Restrict TruePredicate (RelationVariable "s"))])
3635 ]
test/TransactionGraph/Persist.hs+1−1
@@ -40,7 +40,7 @@ testDBSimplePersistence = TestCase $ withSystemTempDirectory "m36testdb" $ \temp
4040 case transactionForHead "master" graph of
4141 Nothing -> assertFailure "Failed to retrieve head transaction for master branch."
4242 Just headTrans -> do
43− case interpretDatabaseExpr (transactionContext headTrans) "x:=S" of
43+ case interpretDatabaseExpr (transactionContext headTrans) "x:=s" of
4444 Left err -> assertFailure (show err)
4545 Right context' -> do
4646 freshUUID' <- nextRandom
test/TutorialD/Interpreter.hs+41−41
@@ -22,8 +22,6 @@ import System.Exit
2222import Data.Maybe (isJust)
2323import qualified Data.Vector as V
2424import Data.Text.Encoding as TE
25−import Data.Typeable (Proxy(..))
26−import Data.Text (Text)
2725import Control.Concurrent.STM
2826import Control.Concurrent
2927import qualified STMContainers.Map as STMMap
@@ -69,46 +67,48 @@ main = do
6967 simpleBAttributes = A.attributesFromList [Attribute "d" intAtomType]
7068 simpleCAttributes = A.attributesFromList [Attribute "a" textAtomType, Attribute "b" intAtomType]
7169 simpleDAttributes = A.attributesFromList [Attribute "a" intAtomType, Attribute "b" intAtomType]
72− simpleMaybeTextAttributes = A.attributesFromList [Attribute "a" $ atomTypeForProxy (Proxy :: Proxy (Maybe Text))]
73− simpleMaybeIntAttributes = A.attributesFromList [Attribute "a" $ atomTypeForProxy (Proxy :: Proxy (Maybe Int))]
70+ maybeTextAtomType = ConstructedAtomType "Maybe" (M.singleton "a" textAtomType)
71+ maybeIntAtomType = ConstructedAtomType "Maybe" (M.singleton "a" intAtomType)
72+ simpleMaybeTextAttributes = A.attributesFromList [Attribute "a" maybeTextAtomType]
73+ simpleMaybeIntAttributes = A.attributesFromList [Attribute "a" maybeIntAtomType]
7474 simpleProjectionAttributes = A.attributesFromList [Attribute "c" intAtomType]
7575 nestedRelationAttributes = A.attributesFromList [Attribute "a" intAtomType, Attribute "b" (RelationAtomType $ A.attributesFromList [Attribute "a" intAtomType])]
7676 extendTestAttributes = A.attributesFromList [Attribute "a" intAtomType, Attribute "b" $ RelationAtomType (attributes suppliersRel)]
7777 byteStringAttributes = A.attributesFromList [Attribute "y" byteStringAtomType]
7878 groupCountAttrs = A.attributesFromList [Attribute "z" intAtomType]
79− minMaxAttrs = A.attributesFromList [Attribute "S#" textAtomType, Attribute "z" intAtomType]
80− dateExampleRelTests = [("x:=S where true", Right suppliersRel),
81− ("x:=S where CITY = \"London\"", restrict (\tuple -> atomForAttributeName "CITY" tuple == (Right $ textAtom "London")) suppliersRel),
82− ("x:=S where false", Right $ Relation (attributes suppliersRel) emptyTupleSet),
83− ("x:=P where COLOR=\"Blue\" and CITY=\"Paris\"", mkRelationFromList (attributes productsRel) [[textAtom "P5", textAtom "Cam", textAtom "Blue", intAtom 12, textAtom "Paris"]]),
84− ("a:=S; update a (STATUS:=50); x:=a{STATUS}", mkRelation (A.attributesFromList [Attribute "STATUS" intAtomType]) (RelationTupleSet [mkRelationTuple (A.attributesFromList [Attribute "STATUS" intAtomType]) (V.fromList [intAtom 50])])),
79+ minMaxAttrs = A.attributesFromList [Attribute "s#" textAtomType, Attribute "z" intAtomType]
80+ dateExampleRelTests = [("x:=s where true", Right suppliersRel),
81+ ("x:=s where city = \"London\"", restrict (\tuple -> atomForAttributeName "city" tuple == (Right $ textAtom "London")) suppliersRel),
82+ ("x:=s where false", Right $ Relation (attributes suppliersRel) emptyTupleSet),
83+ ("x:=p where color=\"Blue\" and city=\"Paris\"", mkRelationFromList (attributes productsRel) [[textAtom "P5", textAtom "Cam", textAtom "Blue", intAtom 12, textAtom "Paris"]]),
84+ ("a:=s; update a (status:=50); x:=a{status}", mkRelation (A.attributesFromList [Attribute "status" intAtomType]) (RelationTupleSet [mkRelationTuple (A.attributesFromList [Attribute "status" intAtomType]) (V.fromList [intAtom 50])])),
8585 --atom function tests
86− ("x:=((S : {STATUS2 := add(10,@STATUS)}) where STATUS2=add(10,@STATUS)){CITY,S#,SNAME,STATUS}", Right suppliersRel),
87− ("x:=S; update x where SNAME=\"Blake\" (CITY:=\"Boston\")", relMap (\tuple -> if atomForAttributeName "SNAME" tuple == (Right $ textAtom "Blake") then updateTuple (M.singleton "CITY" (textAtom "Boston")) tuple else tuple) suppliersRel),
88− ("x:=relation{tuple{a 5}} : {b:=S}", mkRelation extendTestAttributes (RelationTupleSet [mkRelationTuple extendTestAttributes (V.fromList [intAtom 5, Atom suppliersRel])])),
86+ ("x:=((s : {status2 := add(10,@status)}) where status2=add(10,@status)){city,s#,sname,status}", Right suppliersRel),
87+ ("x:=s; update x where sname=\"Blake\" (city:=\"Boston\")", relMap (\tuple -> if atomForAttributeName "sname" tuple == (Right $ textAtom "Blake") then updateTuple (M.singleton "city" (textAtom "Boston")) tuple else tuple) suppliersRel),
88+ ("x:=relation{tuple{a 5}} : {b:=s}", mkRelation extendTestAttributes (RelationTupleSet [mkRelationTuple extendTestAttributes (V.fromList [intAtom 5, Atom suppliersRel])])),
8989 --relatom function tests
90− ("x:=((S group ({CITY} as y)):{z:=count(@y)}){z}", mkRelation groupCountAttrs (RelationTupleSet [mkRelationTuple groupCountAttrs (V.singleton $ intAtom 1)])),
91− ("x:=(SP group ({S#} as y)) ungroup y", Right supplierProductsRel),
92− ("x:=((SP{S#,QTY}) group ({QTY} as x):{z:=max(@x)}){S#,z}", mkRelationFromList minMaxAttrs (map (\(s,i) -> [textAtom s,intAtom i]) [("S1", 400), ("S2", 400), ("S3", 200), ("S4", 400)])),
93− ("x:=((SP{S#,QTY}) group ({QTY} as x):{z:=min(@x)}){S#,z}", mkRelationFromList minMaxAttrs (map (\(s,i) -> [textAtom s,intAtom i]) [("S1", 100), ("S2", 300), ("S3", 200), ("S4", 200)])),
94− ("x:=((SP{S#,QTY}) group ({QTY} as x):{z:=sum(@x)}){S#,z}", mkRelationFromList minMaxAttrs (map (\(s,i) -> [textAtom s,intAtom i]) [("S1", 1000), ("S2", 700), ("S3", 200), ("S4", 900)])),
90+ ("x:=((s group ({city} as y)):{z:=count(@y)}){z}", mkRelation groupCountAttrs (RelationTupleSet [mkRelationTuple groupCountAttrs (V.singleton $ intAtom 1)])),
91+ ("x:=(sp group ({s#} as y)) ungroup y", Right supplierProductsRel),
92+ ("x:=((sp{s#,qty}) group ({qty} as x):{z:=max(@x)}){s#,z}", mkRelationFromList minMaxAttrs (map (\(s,i) -> [textAtom s,intAtom i]) [("S1", 400), ("S2", 400), ("S3", 200), ("S4", 400)])),
93+ ("x:=((sp{s#,qty}) group ({qty} as x):{z:=min(@x)}){s#,z}", mkRelationFromList minMaxAttrs (map (\(s,i) -> [textAtom s,intAtom i]) [("S1", 100), ("S2", 300), ("S3", 200), ("S4", 200)])),
94+ ("x:=((sp{s#,qty}) group ({qty} as x):{z:=sum(@x)}){s#,z}", mkRelationFromList minMaxAttrs (map (\(s,i) -> [textAtom s,intAtom i]) [("S1", 1000), ("S2", 700), ("S3", 200), ("S4", 900)])),
9595 --boolean function restriction
96− ("x:=S where ^lt(@STATUS,20)", mkRelationFromList (attributes suppliersRel) [[textAtom "S2", textAtom "Jones", intAtom 10, textAtom "Paris"]]),
97− ("x:=S where ^gt(@STATUS,20)", mkRelationFromList (attributes suppliersRel) [[textAtom "S3", textAtom "Blake", intAtom 30, textAtom "Paris"],
96+ ("x:=s where ^lt(@status,20)", mkRelationFromList (attributes suppliersRel) [[textAtom "S2", textAtom "Jones", intAtom 10, textAtom "Paris"]]),
97+ ("x:=s where ^gt(@status,20)", mkRelationFromList (attributes suppliersRel) [[textAtom "S3", textAtom "Blake", intAtom 30, textAtom "Paris"],
9898 [textAtom "S5", textAtom "Adams", intAtom 30, textAtom "Athens"]]),
99− ("x:=S where ^sum(@STATUS)", Left $ AtomTypeMismatchError intAtomType boolAtomType),
100− ("x:=S where ^not(gte(@STATUS,20))", mkRelationFromList (attributes suppliersRel) [[textAtom "S2", textAtom "Jones", intAtom 10, textAtom "Paris"]]),
99+ ("x:=s where ^sum(@status)", Left $ AtomTypeMismatchError intAtomType boolAtomType),
100+ ("x:=s where ^not(gte(@status,20))", mkRelationFromList (attributes suppliersRel) [[textAtom "S2", textAtom "Jones", intAtom 10, textAtom "Paris"]]),
101101 --test "all but" attribute inversion syntax
102− ("x:=S{all but S#} = S{CITY,SNAME,STATUS}", Right $ relationTrue),
102+ ("x:=s{all but s#} = s{city,sname,status}", Right $ relationTrue),
103103 --test key syntax
104− ("x:=S; key testconstraint {S#,CITY} x; insert x relation{tuple{CITY \"London\", S# \"S1\", SNAME \"gonk\", STATUS 50}}", Left (InclusionDependencyCheckError "testconstraint")),
105− ("y:=S; key testconstraint {S#} y; insert y relation{tuple{CITY \"London\", S# \"S6\", SNAME \"gonk\", STATUS 50}}; x:=y{S#} = S{S#} union relation{tuple{S# \"S6\"}}", Right $ relationTrue),
104+ ("x:=s; key testconstraint {s#,city} x; insert x relation{tuple{city \"London\", s# \"S1\", sname \"gonk\", status 50}}", Left (InclusionDependencyCheckError "testconstraint")),
105+ ("y:=s; key testconstraint {s#} y; insert y relation{tuple{city \"London\", s# \"S6\", sname \"gonk\", status 50}}; x:=y{s#} = s{s#} union relation{tuple{s# \"S6\"}}", Right $ relationTrue),
106106 --test binary bytestring data type
107− ("x:=relation{tuple{y \"dGVzdGRhdGE=\"::bytestring}}", mkRelationFromList byteStringAttributes [[Atom (TE.encodeUtf8 "testdata")]]),
107+ ("x:=relation{tuple{y makeByteString(\"dGVzdGRhdGE=\")}}", mkRelationFromList byteStringAttributes [[Atom (TE.encodeUtf8 "testdata")]]),
108108 --test Maybe Text
109− ("x:=relation{tuple{a Just \"spam\"}}", mkRelationFromList simpleMaybeTextAttributes [[ConstructedAtom "Just" (ConstructedAtomType "Maybe" (M.singleton "a" textAtomType)) [textAtom "spam"]]]),
109+ ("x:=relation{tuple{a Just \"spam\"}}", mkRelationFromList simpleMaybeTextAttributes [[ConstructedAtom "Just" maybeTextAtomType [textAtom "spam"]]]),
110110 --test Maybe Int
111− ("x:=relation{tuple{a Just 3}}", mkRelationFromList simpleMaybeIntAttributes [[Atom (Just 3 :: Maybe Int)]])
111+ ("x:=relation{tuple{a Just 3}}", mkRelationFromList simpleMaybeIntAttributes [[ConstructedAtom "Just" maybeIntAtomType [intAtom 3]]])
112112 ]
113113
114114assertTutdEqual :: DatabaseContext -> Either RelationalError Relation -> String -> Assertion
@@ -130,7 +130,7 @@ transactionGraphBasicTest = TestCase $ do
130130transactionGraphAddCommitTest :: Test
131131transactionGraphAddCommitTest = TestCase $ do
132132 (sessionId, dbconn) <- dateExamplesConnection emptyNotificationCallback
133− case parseTutorialD "x:=S" of
133+ case parseTutorialD "x:=s" of
134134 Left err -> assertFailure (show err)
135135 Right parsed -> do
136136 result <- evalTutorialD sessionId dbconn parsed
@@ -148,7 +148,7 @@ transactionRollbackTest :: Test
148148transactionRollbackTest = TestCase $ do
149149 (sessionId, dbconn) <- dateExamplesConnection emptyNotificationCallback
150150 graph <- transactionGraph dbconn
151− maybeErr <- executeDatabaseContextExpr sessionId dbconn (Assign "x" (RelationVariable "S"))
151+ maybeErr <- executeDatabaseContextExpr sessionId dbconn (Assign "x" (RelationVariable "s"))
152152 case maybeErr of
153153 Just err -> assertFailure (show err)
154154 Nothing -> do
@@ -163,7 +163,7 @@ transactionJumpTest :: Test
163163transactionJumpTest = TestCase $ do
164164 (sessionId, dbconn) <- dateExamplesConnection emptyNotificationCallback
165165 (DisconnectedTransaction firstUUID _) <- disconnectedTransaction sessionId dbconn
166− maybeErr <- executeDatabaseContextExpr sessionId dbconn (Assign "x" (RelationVariable "S"))
166+ maybeErr <- executeDatabaseContextExpr sessionId dbconn (Assign "x" (RelationVariable "s"))
167167 case maybeErr of
168168 Just err -> assertFailure (show err)
169169 Nothing -> do
@@ -186,24 +186,24 @@ transactionBranchTest :: Test
186186transactionBranchTest = TestCase $ do
187187 (sessionId, dbconn) <- dateExamplesConnection emptyNotificationCallback
188188 mapM_ (\x -> x >>= maybeFail) [executeGraphExpr sessionId dbconn (Branch "test"),
189− executeDatabaseContextExpr sessionId dbconn (Assign "x" (RelationVariable "S")),
189+ executeDatabaseContextExpr sessionId dbconn (Assign "x" (RelationVariable "s")),
190190 commit sessionId dbconn,
191191 executeGraphExpr sessionId dbconn (JumpToHead "master"),
192− executeDatabaseContextExpr sessionId dbconn (Assign "y" (RelationVariable "S"))
192+ executeDatabaseContextExpr sessionId dbconn (Assign "y" (RelationVariable "s"))
193193 ]
194194 graph <- transactionGraph dbconn
195195 assertBool "master branch exists" $ isJust (transactionForHead "master" graph)
196196 assertBool "test branch exists" $ isJust (transactionForHead "test" graph)
197197
198198simpleJoinTest :: Test
199−simpleJoinTest = TestCase $ assertTutdEqual dateExamples joinedRel "x:=S join SP"
199+simpleJoinTest = TestCase $ assertTutdEqual dateExamples joinedRel "x:=s join sp"
200200 where
201− attrs = A.attributesFromList [Attribute "CITY" textAtomType,
202− Attribute "QTY" intAtomType,
203− Attribute "P#" textAtomType,
204− Attribute "S#" textAtomType,
205− Attribute "SNAME" textAtomType,
206− Attribute "STATUS" intAtomType]
201+ attrs = A.attributesFromList [Attribute "city" textAtomType,
202+ Attribute "qty" intAtomType,
203+ Attribute "p#" textAtomType,
204+ Attribute "s#" textAtomType,
205+ Attribute "sname" textAtomType,
206+ Attribute "status" intAtomType]
207207 joinedRel = mkRelationFromList attrs [[textAtom "London", intAtom 100, textAtom "P6", textAtom "S1", textAtom "Smith", intAtom 20],
208208 [textAtom "London", intAtom 400, textAtom "P3", textAtom "S1", textAtom "Smith", intAtom 20],
209209 [textAtom "London", intAtom 400, textAtom "P5", textAtom "S4", textAtom "Clark", intAtom 20],
@@ -260,7 +260,7 @@ testNotification = TestCase $ do
260260 let notifCallback mvar = \_ _ -> putMVar mvar ()
261261 relvarx = RelationVariable "x"
262262 (sess, conn) <- dateExamplesConnection (notifCallback notifmvar)
263− let check' x = x >>= maybe (pure ()) (\err -> assertFailure (show err))
263+ let check' x = x >>= maybe (pure ()) (\err -> assertFailure (show err))
264264 check' $ executeDatabaseContextExpr sess conn (Assign "x" (ExistingRelation relationTrue))
265265 check' $ executeDatabaseContextExpr sess conn (AddNotification "test notification" relvarx relvarx)
266266 check' $ commit sess conn
test/TutorialD/Interpreter/Import/TutorialD.hs+2−3
@@ -7,7 +7,7 @@ import qualified ProjectM36.Attribute as A
77import TutorialD.Interpreter.Import.TutorialD
88import System.Exit
99import System.IO.Temp
10−import qualified Data.Vector as V
10+import qualified Data.Map as M
1111import System.IO
1212
1313main :: IO ()
@@ -20,7 +20,6 @@ testTutdImport = TestCase $ do
2020 withSystemTempFile "m.tutd" $ \tempPath handle -> do
2121 hPutStrLn handle "x:=relation{tuple{a 5,b \"spam\"}}"
2222 hClose handle
23− let expectedExpr = MultipleExpr [Assign "x" (ExistingRelation (Relation expectedAttrs $ RelationTupleSet [RelationTuple expectedAttrs $ V.fromList [intAtom 5, textAtom "spam"]]))]
24− expectedAttrs = A.attributesFromList [Attribute "a" intAtomType, Attribute "b" textAtomType]
23+ let expectedExpr = MultipleExpr [Assign "x" (MakeRelationFromExprs Nothing [TupleExpr (M.fromList [("a",NakedAtomExpr $ intAtom 5),("b",NakedAtomExpr $ textAtom "spam")])])]
2524 imported <- importTutorialD tempPath
2625 assertEqual "import tutd" (Right expectedExpr) imported