@@ -3,35 +3,45 @@ import ProjectM36.Base
33import ProjectM36.Relation
44import ProjectM36.Tuple
55import ProjectM36.Relation.Show.CSV
6+import ProjectM36.Relation.Show.HTML
7+import TutorialD.Interpreter (interpret)
8+import ProjectM36.RelationalExpression
69import qualified Data.HashSet as HS
710import qualified Data.ByteString.Lazy.Char8 as BS
811import qualified Data.IntMap as IM
912import qualified Data.Hashable as Hash
1013import qualified Data.Vector as V
1114import Options.Applicative
15+import Control.Monad.State
16+import qualified Data.Map as M
17+import qualified Data.Text.IO as TIO
18+import System.IO
1219
1320dumpcsv :: Relation -> IO ()
1421dumpcsv = BS.putStrLn . relationAsCSV
1522
23+data BigrelArgs = BigrelArgs Int Int String
24+
1625parseAttributeCount :: Parser Int
1726parseAttributeCount = option auto (short 'a' <> long "attribute-count")
1827
1928parseTupleCount :: Parser Int
2029parseTupleCount = option auto (short 't' <> long "tuple-count")
21−
22−parseArgs :: Parser (Int, Int)
23−parseArgs = (,) <$> parseAttributeCount <*> parseTupleCount
2430
31+parseTutD :: Parser String
32+parseTutD = strOption (short 'd' <> long "tutoriald")
33+
34+parseArgs :: Parser BigrelArgs
35+parseArgs = BigrelArgs <$> parseAttributeCount <*> parseTupleCount <*> parseTutD
2536
2637main :: IO ()
2738main = do
28− (attributeCount, tupleCount) <- execParser $ info (helper <*> parseArgs) fullDesc
39+ bigrelArgs <- execParser $ info (helper <*> parseArgs) fullDesc
2940 --matrixRestrictRun
30− matrixRun attributeCount tupleCount
41+ matrixRun bigrelArgs
3142 --vectorMatrixRun
3243 --intmapMatrixRun
3344
34−-- takes 30 minutes to run and 1.1 GB
3545matrixRestrictRun :: IO ()
3646matrixRestrictRun = do
3747 case matrixRelation 100 1000000 of
@@ -40,11 +50,20 @@ matrixRestrictRun = do
4050 Left err -> putStrLn (show err)
4151 Right rel -> dumpcsv rel
4252
43−matrixRun :: Int -> Int -> IO ()
44−matrixRun attributeCount tupleCount= do
53+matrixRun :: BigrelArgs -> IO ()
54+matrixRun (BigrelArgs attributeCount tupleCount tutd) = do
4555 case matrixRelation attributeCount tupleCount of
4656 Left err -> putStrLn (show err)
47− Right rel -> putStrLn "Done"
57+ Right rel -> if tutd == "" then
58+ putStrLn "Done."
59+ else do
60+ let setx = Assign "x" (ExistingRelation rel)
61+ (_, context) = runState (evalContextExpr setx) dateExamples
62+ (err, context2) = interpret context tutd
63+ case err of
64+ Nothing -> TIO.putStrLn $ relationAsHTML ((relationVariables context2) M.! "x")
65+ Just err -> hPutStrLn stderr (show err)
66+
4867
4968intmapMatrixRun :: IO ()
5069intmapMatrixRun = do