aboutsummaryrefslogtreecommitdiff
path: root/bin/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/Main.hs')
-rw-r--r--bin/Main.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/Main.hs b/bin/Main.hs
index a088fdb..54ed6b2 100644
--- a/bin/Main.hs
+++ b/bin/Main.hs
@@ -2,8 +2,9 @@ module Main where
2 2
3import Control.Monad (liftM) 3import Control.Monad (liftM)
4import Control.Monad.Except (throwError) 4import Control.Monad.Except (throwError)
5import Error (LispError (..), LispResult (..), 5import Error.Base (LispError (..), LispResult (..),
6 unwrap) 6 unwrap)
7import Error.Pretty (defaults, showError)
7import Evaluator (eval) 8import Evaluator (eval)
8import Parser (Expr (..), parseLispValue) 9import Parser (Expr (..), parseLispValue)
9import System.Console.Readline 10import System.Console.Readline
@@ -12,7 +13,7 @@ import Text.ParserCombinators.Parsec
12 13
13readExpr :: String -> LispResult Expr 14readExpr :: String -> LispResult Expr
14readExpr inp = 15readExpr inp =
15 case parse parseLispValue "(unknown)" inp of 16 case parse parseLispValue "(lisk-repl)" inp of
16 Left err -> throwError $ Parse err 17 Left err -> throwError $ Parse err
17 Right val -> return val 18 Right val -> return val
18 19
@@ -26,7 +27,8 @@ repl = do
26 Just ",q" -> return () 27 Just ",q" -> return ()
27 Just line -> do 28 Just line -> do
28 addHistory line 29 addHistory line
29 putStrLn $ either show show $ eval =<< readExpr line 30 let pp = showError defaults
31 either (putStrLn . pp line) print $ readExpr line >>= eval
30 repl 32 repl
31 33
32main :: IO () 34main :: IO ()