blob: 3cada6364cc77cc93ba18e32bf65c9bf1ec3744e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
module Expr where
-- data X = Expr | Imag | Matrix
data Expr = Expr Term Expr | ExprSingle Term
data Term = Term Factor Term | TermSingle Factor
data Factor = Factor Base Factor | FactorSingle Base
data Base = Base Expr | BaseSingle Float
instance Show Expr where
show (ExprSingle t) = show t
show (Expr t e) = show t ++ " + " ++ show e
instance Show Term where
show (TermSingle f) = show f
show (Term f t) = show f ++ " * " ++ show t
instance Show Factor where
show (FactorSingle b) = show b
show (Factor b f) = show b ++ " ^ " ++ show f
instance Show Base where
show (BaseSingle x) = show x
show (Base e) = "( " ++ show e ++ " )"
|