diff options
author | Ben Sima <ben@bsima.me> | 2019-03-23 23:58:26 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2019-03-23 23:58:26 -0700 |
commit | f50cecf2cb77cc073cb86a6016468a09d1c49fb0 (patch) | |
tree | 1ca9eda0a93a2e04e2dc44df8fc5113375a72c3d /lore/Language/Bs/Repl.hs | |
parent | 5d4e34f146a358041099299d2f86a546eed25dea (diff) |
Add semi-working bs
Diffstat (limited to 'lore/Language/Bs/Repl.hs')
-rw-r--r-- | lore/Language/Bs/Repl.hs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lore/Language/Bs/Repl.hs b/lore/Language/Bs/Repl.hs new file mode 100644 index 0000000..bd8acca --- /dev/null +++ b/lore/Language/Bs/Repl.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE OverloadedStrings #-} +module Language.Bs.Repl ( + mainLoop, +) where + +import Language.Bs.Eval +import Data.Text as T +import Control.Monad.Trans +import System.Console.Haskeline + +type Repl a = InputT IO a + +mainLoop :: IO () +mainLoop = runInputT defaultSettings repl + +repl :: Repl () +repl = do + minput <- getInputLine "bs> " + case minput of + Nothing -> outputStrLn "bye." + Just input -> liftIO (process input) >> repl + --Just input -> (liftIO $ processToAST input) >> repl + +process :: String -> IO () +process str = do + res <- safeExec $ evalText $ T.pack str + either putStrLn return res + +processToAST :: String -> IO () +processToAST str = print $ runParseTest $ T.pack str |