aboutsummaryrefslogtreecommitdiff
path: root/src/expr.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/expr.hs')
-rw-r--r--src/expr.hs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/expr.hs b/src/expr.hs
new file mode 100644
index 0000000..3cada63
--- /dev/null
+++ b/src/expr.hs
@@ -0,0 +1,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 ++ " )"