diff options
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 |