diff options
author | Ben Sima <ben@bsima.me> | 2019-11-23 15:59:08 -0800 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2019-11-23 15:59:08 -0800 |
commit | cc64fa01e9bae297915906a03f85fe50be384990 (patch) | |
tree | 0edce8775852170464cad7408c3c81dec8ad9bf6 /Com/Simatime/Language/Bs/Repl.hs | |
parent | cb6147436f5cdc42622e849cfd6612261704b839 (diff) |
Capitalize all Scheme and Haskell modules
Diffstat (limited to 'Com/Simatime/Language/Bs/Repl.hs')
-rw-r--r-- | Com/Simatime/Language/Bs/Repl.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Com/Simatime/Language/Bs/Repl.hs b/Com/Simatime/Language/Bs/Repl.hs new file mode 100644 index 0000000..64ffaa2 --- /dev/null +++ b/Com/Simatime/Language/Bs/Repl.hs @@ -0,0 +1,33 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE NoImplicitPrelude #-} +module Language.Bs.Repl ( +mainLoop +) where + +import Control.Monad.Trans +import Data.String +import Data.Text as T +import Language.Bs.Eval +import Protolude +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 |