1
1
mirror of https://github.com/kanaka/mal.git synced 2024-11-10 12:47:45 +03:00
mal/haskell/step0_repl.hs
Joel Martin 5400d4bf5e Haskell: add error handling and try*/catch*.
Achieve self-hosting!
2015-01-09 16:16:54 -06:00

29 lines
457 B
Haskell

import System.IO (hFlush, stdout)
import Readline (readline, load_history)
-- read
mal_read str = str
-- eval
eval ast env = ast
-- print
mal_print exp = exp
-- repl
rep line = mal_print $ eval (mal_read line) ""
repl_loop = do
line <- readline "user> "
case line of
Nothing -> return ()
Just "" -> repl_loop
Just str -> do
putStrLn $ rep str
repl_loop
main = do
load_history
repl_loop