mirror of
https://github.com/kanaka/mal.git
synced 2024-11-10 12:47:45 +03:00
5400d4bf5e
Achieve self-hosting!
29 lines
457 B
Haskell
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
|