-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.hs
More file actions
39 lines (36 loc) · 1.19 KB
/
Main.hs
File metadata and controls
39 lines (36 loc) · 1.19 KB
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
module Main where
import Control.Monad.IO.Class ( liftIO )
import System.Console.Haskeline
import ParseInput ( lambdaInteract )
import Util
main :: IO ()
main = do
putStr "\ESC[2J"
putStrLn $ unlines
[ mkBold "KIT programming paradigms" Nothing
, mkBold "Lambda Calculus Interpreter" Nothing
, " © dnlkrgr.com"
, ""
, mkItalic "Usage:" Nothing
, "- enter lambda expressions and let them be evaluated"
, " by hitting enter"
, "- quit by writing \"quit\"."
, ""
, mkItalic "Example lambda expressions:" Nothing
, "number: 3"
, "variable: x, y, z"
, "lambda: /x. x, /x. /y. x"
, "application: $ f g, $ ($ a b) c, $ f (/x.x)"
]
runInputT defaultSettings loop
where
loop :: InputT IO ()
loop = do
minput <- getInputLine (mkBold "λ> " Nothing)
case minput of
Nothing -> return ()
Just "quit" -> return ()
Just input -> do
output <- liftIO $ lambdaInteract input
mapM_ outputStrLn output
loop