@@ -3,35 +3,45 @@ import ProjectM36.Base
3import ProjectM36.Relation
3import ProjectM36.Relation
4import ProjectM36.Tuple
4import ProjectM36.Tuple
5import ProjectM36.Relation.Show.CSV
5import ProjectM36.Relation.Show.CSV
6+import ProjectM36.Relation.Show.HTML
7+import TutorialD.Interpreter (interpret)
8+import ProjectM36.RelationalExpression
6import qualified Data.HashSet as HS
9import qualified Data.HashSet as HS
7import qualified Data.ByteString.Lazy.Char8 as BS
10import qualified Data.ByteString.Lazy.Char8 as BS
8import qualified Data.IntMap as IM
11import qualified Data.IntMap as IM
9import qualified Data.Hashable as Hash
12import qualified Data.Hashable as Hash
10import qualified Data.Vector as V
13import qualified Data.Vector as V
11import Options.Applicative
14import Options.Applicative
15+import Control.Monad.State
16+import qualified Data.Map as M
17+import qualified Data.Text.IO as TIO
13dumpcsv :: Relation -> IO ()
20dumpcsv :: Relation -> IO ()
14dumpcsv = BS.putStrLn . relationAsCSV
21dumpcsv = BS.putStrLn . relationAsCSV
23+data BigrelArgs = BigrelArgs Int Int String
16parseAttributeCount :: Parser Int
25parseAttributeCount :: Parser Int
17parseAttributeCount = option auto (short 'a' <> long "attribute-count")
26parseAttributeCount = option auto (short 'a' <> long "attribute-count")
19parseTupleCount :: Parser Int
28parseTupleCount :: Parser Int
20parseTupleCount = option auto (short 't' <> long "tuple-count")
29parseTupleCount = option auto (short 't' <> long "tuple-count")
22−parseArgs :: Parser (Int, Int)
23−parseArgs = (,) <$> parseAttributeCount <*> parseTupleCount
31+parseTutD :: Parser String
32+parseTutD = strOption (short 'd' <> long "tutoriald")
34+parseArgs :: Parser BigrelArgs
35+parseArgs = BigrelArgs <$> parseAttributeCount <*> parseTupleCount <*> parseTutD
26main :: IO ()
37main :: IO ()
28− (attributeCount, tupleCount) <- execParser $ info (helper <*> parseArgs) fullDesc
39+ bigrelArgs <- execParser $ info (helper <*> parseArgs) fullDesc
29 --matrixRestrictRun
40 --matrixRestrictRun
30− matrixRun attributeCount tupleCount
41+ matrixRun bigrelArgs
31 --vectorMatrixRun
42 --vectorMatrixRun
32 --intmapMatrixRun
43 --intmapMatrixRun
34−-- takes 30 minutes to run and 1.1 GB
35matrixRestrictRun :: IO ()
45matrixRestrictRun :: IO ()
36matrixRestrictRun = do
46matrixRestrictRun = do
37 case matrixRelation 100 1000000 of
47 case matrixRelation 100 1000000 of
@@ -40,11 +50,20 @@ matrixRestrictRun = do
40 Left err -> putStrLn (show err)
50 Left err -> putStrLn (show err)
41 Right rel -> dumpcsv rel
51 Right rel -> dumpcsv rel
43−matrixRun :: Int -> Int -> IO ()
53+matrixRun :: BigrelArgs -> IO ()
44−matrixRun attributeCount tupleCount= do
54+matrixRun (BigrelArgs attributeCount tupleCount tutd) = do
45 case matrixRelation attributeCount tupleCount of
55 case matrixRelation attributeCount tupleCount of
46 Left err -> putStrLn (show err)
56 Left err -> putStrLn (show err)
57+ Right rel -> if tutd == "" then
47− Right rel -> putStrLn "Done"
58+ putStrLn "Done."
60+ let setx = Assign "x" (ExistingRelation rel)
61+ (_, context) = runState (evalContextExpr setx) dateExamples
62+ (err, context2) = interpret context tutd
64+ Nothing -> TIO.putStrLn $ relationAsHTML ((relationVariables context2) M.! "x")
65+ Just err -> hPutStrLn stderr (show err)
49intmapMatrixRun :: IO ()
68intmapMatrixRun :: IO ()
50intmapMatrixRun = do
69intmapMatrixRun = do