-
Notifications
You must be signed in to change notification settings - Fork 0
/
Expr.hs
32 lines (28 loc) · 1.02 KB
/
Expr.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
module Expr where
import Data.Map (Map)
type Context = Map String Expr
data Expr = LispFloat Double |
LispInteger Integer |
LispBoolean Bool |
LispChar Char |
LispFunction (Context -> [Expr] -> (Context, Expr)) |
LispSymbol String |
LispDataList [Expr] |
LispRangeList Expr Expr |
LispRangeList2 Expr Expr Expr |
LispInfRangeList Expr |
LispInfRangeList2 Expr Expr |
LispList [Expr] |
LispError String |
LispDo [Expr]
instance Show Expr where
show (LispFloat val) = show val
show (LispInteger val) = show val
show (LispBoolean val) = if val then "true" else "false"
show (LispChar val) = show val
show (LispFunction _) = "[function]"
show (LispSymbol val) = val
show (LispDataList val) = "[" ++ unwords (map show val) ++ "]"
show (LispList val) = "(" ++ unwords (map show val) ++ ")"
show (LispError val) = "Error : " ++ val
show _ = "[undefined]"