-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.hs
43 lines (39 loc) · 1.05 KB
/
main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Lambda
import Parser
import Expr
import Tests.Examples
import System.IO
default_ctx :: [(String, Expr)]
default_ctx = [ ("true", ltrue)
, ("false", lfalse)
, ("and", land)
, ("or", lor)
, ("not", lnot)
, ("zero", zero)
, ("succ", nsucc)
, ("add", add)
, ("mult", mult)
, ("iszero", iszero)
, ("m", m)
, ("i", i)
, ("k", k)
, ("ki", ki)
, ("c", c)
, ("b", b)
, ("y", y)
]
main :: IO ()
main = lambda default_ctx
lambda :: [(String, Expr)] -> IO ()
lambda ctx = do
putStr "λ> "
hFlush stdout
input <- getLine
case input of
"exit" -> return ()
_ -> case parse_code input of
(Evaluate e) -> do
putStrLn $ show $ reduceN (evalMacros ctx e)
lambda ctx
(Assign s e) -> do
lambda ((s, evalMacros ctx e):ctx)