From f50cecf2cb77cc073cb86a6016468a09d1c49fb0 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 23 Mar 2019 23:58:26 -0700 Subject: Add semi-working bs --- lore/Language/Bs/Repl.hs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lore/Language/Bs/Repl.hs (limited to 'lore/Language/Bs/Repl.hs') 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 -- cgit v1.2.3