2021-02-24 17:50:53 +00:00
|
|
|
module Expression where
|
|
|
|
|
|
|
|
-- The basic unit of the language are Expressions, so we make an
|
|
|
|
-- Expression data with the primitive expression values as the
|
|
|
|
-- constructors
|
2021-02-27 23:20:42 +00:00
|
|
|
|
2021-02-24 17:50:53 +00:00
|
|
|
data Expression = Number Double
|
|
|
|
| Symbol String
|
|
|
|
| SExpr [Expression]
|
|
|
|
deriving (Eq)
|
|
|
|
|
|
|
|
instance Show Expression where
|
|
|
|
show (Number n) = show n
|
|
|
|
show (Symbol s) = show s
|
|
|
|
show (SExpr es) = "(" ++ unwords (map show es) ++ ")"
|