Add basic repl
authorLuke Lau <luke_lau@icloud.com>
Sat, 18 May 2019 20:11:11 +0000 (21:11 +0100)
committerLuke Lau <luke_lau@icloud.com>
Sun, 19 May 2019 13:17:16 +0000 (14:17 +0100)
For the moment this doesn't have any parsing errors other than "Couldn't
parse". We'll go back to this later!
Also note we're printing to stderr.

Main.hs

diff --git a/Main.hs b/Main.hs
index 76a9bdb5d48831da2e59c811ecbcbb5a379bdfb5..ec0de8c8bcfd731b298ed5a09c5df8784e9f0fd3 100644 (file)
--- a/Main.hs
+++ b/Main.hs
@@ -1 +1,10 @@
-main = pure ()
+import AST
+import System.IO
+import Text.Read
+main = do
+  hPutStr stderr "ready> "
+  ast <- (readMaybe <$> getLine) :: IO (Maybe AST)
+  case ast of
+    Just x -> hPrint stderr x
+    Nothing ->  hPutStrLn stderr "Couldn't parse"
+  main