aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/Main.hs13
1 files changed, 5 insertions, 8 deletions
diff --git a/bin/Main.hs b/bin/Main.hs
index c66d328..18e1c53 100644
--- a/bin/Main.hs
+++ b/bin/Main.hs
@@ -20,7 +20,7 @@ readExpr inp =
20 20
21evalExpr :: Env -> String -> IO (LispResult String) 21evalExpr :: Env -> String -> IO (LispResult String)
22evalExpr env inp = runExceptT $ fmap show $ 22evalExpr env inp = runExceptT $ fmap show $
23 (liftLispResult $ readExpr inp) >>= eval env 23 liftLispResult (readExpr inp) >>= eval env
24 24
25repl :: Env -> IO () 25repl :: Env -> IO ()
26repl env = do 26repl env = do
@@ -29,20 +29,17 @@ repl env = do
29 case inp of 29 case inp of
30 Nothing -> return () 30 Nothing -> return ()
31 Just ",q" -> return () 31 Just ",q" -> return ()
32 Just i -> do 32 Just i -> evalExpr env i >>= either (putStrLn . pp i) putStrLn >> repl env
33 out <- evalExpr env i
34 either (putStrLn . pp i) putStrLn out
35 repl env
36 33
37 34
38main :: IO () 35main :: IO ()
39main = do 36main = do
40 args <- getArgs 37 args <- getArgs
41 initEnv <- newEnv 38 env <- newEnv
42 if null args 39 if null args
43 then do 40 then do
44 putStrLn ";;; Entering lisk repl ..." 41 putStrLn ";;; Entering lisk repl ..."
45 repl initEnv 42 repl env
46 else do 43 else do
47 let pp = showError defaults "(lisk-repl)" 44 let pp = showError defaults "(lisk-repl)"
48 evalExpr initEnv (head args) >>= (either (putStrLn . pp) print) 45 evalExpr env (head args) >>= either (putStrLn . pp) print