2014-12-25 09:17:38 +03:00
|
|
|
import System.IO (hFlush, stdout)
|
2014-12-24 06:35:48 +03:00
|
|
|
|
2014-12-24 08:37:43 +03:00
|
|
|
import Readline (readline, load_history)
|
|
|
|
|
2014-12-24 06:35:48 +03:00
|
|
|
-- 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
|
2014-12-24 08:37:43 +03:00
|
|
|
line <- readline "user> "
|
|
|
|
case line of
|
|
|
|
Nothing -> return ()
|
|
|
|
Just "" -> repl_loop
|
|
|
|
Just str -> do
|
|
|
|
putStrLn $ rep str
|
|
|
|
repl_loop
|
2014-12-24 06:35:48 +03:00
|
|
|
|
2014-12-24 08:37:43 +03:00
|
|
|
main = do
|
|
|
|
load_history
|
|
|
|
repl_loop
|