0
@@ -42,149 +42,126 @@ instance Show Binding where
0
- | EIfThenElse Expression Expression Expression
0
-instance Show Expression where
0
- show EBottom = "Bottom"
0
- show (ENumber n) = show n
0
- show (ESequence s) = show s
0
- show (ESet a) = show a
0
- show (EBoolean b) = show b
0
- show (ETuple t) = show t
0
- show (QHead x) = "head(" ++ show x ++ ")"
0
- show (EIfThenElse b x y) = "if (" ++ show b ++ ") then " ++
0
- show x ++ " else " ++ show y
0
- -- We don't want to show the [] brackets when showing a list of
0
- -- expressions, since we're going to use different brackets
0
- -- depending on whether the list represents a sequence, set, or
0
- showList [] = showString ""
0
- showList (x:xs) = shows x . showl xs
0
- showl (x:xs) = showChar ',' . shows x . showl xs
0
- | NSum Expression Expression
0
- | NDiff Expression Expression
0
- | NProd Expression Expression
0
- | NQuot Expression Expression
0
- | NRem Expression Expression
0
- | SCardinality Expression
0
-instance Show Number where
0
- show (NLit i) = show i
0
- show (NNeg m) = "(-" ++ show m ++ ")"
0
- show (NSum m n) = "(" ++ show m ++ " + " ++ show n ++ ")"
0
- show (NDiff m n) = "(" ++ show m ++ " - " ++ show n ++ ")"
0
- show (NProd m n) = "(" ++ show m ++ " * " ++ show n ++ ")"
0
- show (NQuot m n) = "(" ++ show m ++ " / " ++ show n ++ ")"
0
- show (NRem m n) = "(" ++ show m ++ " % " ++ show n ++ ")"
0
- show (QLength s) = "(#" ++ show s ++ ")"
0
- show (SCardinality a) = "(#" ++ show a ++ ")"
0
- | QClosedRange Expression Expression
0
- | QOpenRange Expression
0
- | QConcat Expression Expression
0
+ -- Expressions which evaluate to a number
0
+ | ENSum Expression Expression
0
+ | ENDiff Expression Expression
0
+ | ENProd Expression Expression
0
+ | ENQuot Expression Expression
0
+ | ENRem Expression Expression
0
+ | ESCardinality Expression
0
+ -- Expressions which evaluate to a sequence
0
+ | EQClosedRange Expression Expression
0
+ | EQOpenRange Expression
0
+ | EQConcat Expression Expression
0
-- TODO: sequence comprehension
0
-instance Show Sequence where
0
- show (QLit xs) = "<" ++ show xs ++ ">"
0
- show (QClosedRange m n) = "<" ++ show m ++ ".." ++ show n ++ ">"
0
- show (QOpenRange m) = "<" ++ show m ++ "..>"
0
- show (QConcat s t) = "concat(" ++ show s ++ ", " ++ show t ++ ")"
0
- show (QTail s) = "tail(" ++ show s ++ ")"
0
- | SClosedRange Expression Expression
0
- | SOpenRange Expression
0
- | SUnion Expression Expression
0
- | SIntersection Expression Expression
0
- | SDifference Expression Expression
0
- | SDistUnion Expression
0
- | SDistIntersection Expression
0
- | SPowerset Expression
0
- | SSequenceset Expression
0
+ -- Expressions which evaluate to a set
0
+ | ESClosedRange Expression Expression
0
+ | ESOpenRange Expression
0
+ | ESUnion Expression Expression
0
+ | ESIntersection Expression Expression
0
+ | ESDifference Expression Expression
0
+ | ESDistUnion Expression
0
+ | ESDistIntersection Expression
0
+ | ESPowerset Expression
0
+ | ESSequenceset Expression
0
-- TODO: set comprehension
0
-instance Show Set where
0
- show (SLit xs) = "{" ++ show xs ++ "}"
0
- show (SClosedRange m n) = "{" ++ show m ++ ".." ++ show n ++ "}"
0
- show (SOpenRange m) = "{" ++ show m ++ "..}"
0
- show (SUnion s1 s2) = "union(" ++ show s1 ++ ", " ++ show s2 ++ "}"
0
- show (SIntersection s1 s2) = "inter(" ++ show s1 ++ ", " ++ show s2 ++ "}"
0
- show (SDifference s1 s2) = "diff(" ++ show s1 ++ ", " ++ show s2 ++ "}"
0
- show (SDistUnion s1) = "Union(" ++ show s1 ++ ")"
0
- show (SDistIntersection s1) = "Inter(" ++ show s1 ++ ")"
0
- show (QSet q0) = "set(" ++ show q0 ++ ")"
0
- show (SPowerset s1) = "Set(" ++ show s1 ++ ")"
0
- show (SSequenceset s1) = "Seq(" ++ show s1 ++ ")"
0
- | BAnd Expression Expression
0
- | BOr Expression Expression
0
+ -- Expressions which evaluate to a boolean
0
+ | EBAnd Expression Expression
0
+ | EBOr Expression Expression
0
| EEqual Expression Expression
0
| ENotEqual Expression Expression
0
| ELT Expression Expression
0
| EGT Expression Expression
0
| ELTE Expression Expression
0
| EGTE Expression Expression
0
- | QIn Expression Expression
0
- | SIn Expression Expression
0
+ | EQIn Expression Expression
0
+ | ESIn Expression Expression
0
+ -- Expressions which evaluate to a tuple
0
+ -- Expressions which can evaluate to anything
0
+ | EIfThenElse Expression Expression Expression
0
-instance Show Boolean where
0
- show (BAnd b1 b2) = "(" ++ show b1 ++ " && " ++ show b2 ++ ")"
0
- show (BOr b1 b2) = "(" ++ show b1 ++ " || " ++ show b2 ++ ")"
0
- show (BNot b1) = "(!" ++ show b1 ++ ")"
0
+instance Show Expression where
0
+ show EBottom = "Bottom"
0
+ show (ENLit i) = show i
0
+ show (ENNeg m) = "(-" ++ show m ++ ")"
0
+ show (ENSum m n) = "(" ++ show m ++ " + " ++ show n ++ ")"
0
+ show (ENDiff m n) = "(" ++ show m ++ " - " ++ show n ++ ")"
0
+ show (ENProd m n) = "(" ++ show m ++ " * " ++ show n ++ ")"
0
+ show (ENQuot m n) = "(" ++ show m ++ " / " ++ show n ++ ")"
0
+ show (ENRem m n) = "(" ++ show m ++ " % " ++ show n ++ ")"
0
+ show (EQLength s) = "(#" ++ show s ++ ")"
0
+ show (ESCardinality a) = "(#" ++ show a ++ ")"
0
+ show (EQLit xs) = "<" ++ show xs ++ ">"
0
+ show (EQClosedRange m n) = "<" ++ show m ++ ".." ++ show n ++ ">"
0
+ show (EQOpenRange m) = "<" ++ show m ++ "..>"
0
+ show (EQConcat s t) = "concat(" ++ show s ++ ", " ++ show t ++ ")"
0
+ show (EQTail s) = "tail(" ++ show s ++ ")"
0
+ show (ESLit xs) = "{" ++ show xs ++ "}"
0
+ show (ESClosedRange m n) = "{" ++ show m ++ ".." ++ show n ++ "}"
0
+ show (ESOpenRange m) = "{" ++ show m ++ "..}"
0
+ show (ESUnion s1 s2) = "union(" ++ show s1 ++ ", " ++ show s2 ++ "}"
0
+ show (ESIntersection s1 s2) = "inter(" ++ show s1 ++ ", " ++ show s2 ++ "}"
0
+ show (ESDifference s1 s2) = "diff(" ++ show s1 ++ ", " ++ show s2 ++ "}"
0
+ show (ESDistUnion s1) = "Union(" ++ show s1 ++ ")"
0
+ show (ESDistIntersection s1) = "Inter(" ++ show s1 ++ ")"
0
+ show (EQSet q0) = "set(" ++ show q0 ++ ")"
0
+ show (ESPowerset s1) = "Set(" ++ show s1 ++ ")"
0
+ show (ESSequenceset s1) = "Seq(" ++ show s1 ++ ")"
0
+ show EBFalse = "false"
0
+ show (EBAnd b1 b2) = "(" ++ show b1 ++ " && " ++ show b2 ++ ")"
0
+ show (EBOr b1 b2) = "(" ++ show b1 ++ " || " ++ show b2 ++ ")"
0
+ show (EBNot b1) = "(!" ++ show b1 ++ ")"
0
show (EEqual e1 e2) = "(" ++ show e1 ++ " == " ++ show e2 ++ ")"
0
show (ENotEqual e1 e2) = "(" ++ show e1 ++ " != " ++ show e2 ++ ")"
0
show (ELT e1 e2) = "(" ++ show e1 ++ " < " ++ show e2 ++ ")"
0
show (EGT e1 e2) = "(" ++ show e1 ++ " > " ++ show e2 ++ ")"
0
show (ELTE e1 e2) = "(" ++ show e1 ++ " <= " ++ show e2 ++ ")"
0
show (EGTE e1 e2) = "(" ++ show e1 ++ " >= " ++ show e2 ++ ")"
0
- show (QEmpty q0) = "null(" ++ show q0 ++ ")"
0
- show (QIn x q0) = "elem(" ++ show x ++ ", " ++ show q0 ++ ")"
0
- show (SIn x s0) = "member(" ++ show x ++ ", " ++ show s0 ++ ")"
0
- show (SEmpty s0) = "empty(" ++ show s0 ++ ")"
0
+ show (EQEmpty q0) = "null(" ++ show q0 ++ ")"
0
+ show (EQIn x q0) = "elem(" ++ show x ++ ", " ++ show q0 ++ ")"
0
+ show (ESIn x s0) = "member(" ++ show x ++ ", " ++ show s0 ++ ")"
0
+ show (ESEmpty s0) = "empty(" ++ show s0 ++ ")"
0
+ show (ETLit xs) = "(" ++ show xs ++ ")"
0
+ show (EQHead x) = "head(" ++ show x ++ ")"
0
+ show (EIfThenElse b x y) = "if (" ++ show b ++ ") then " ++
0
+ show x ++ " else " ++ show y
0
- deriving (Eq, Ord, Show)
0
+ -- We don't want to show the [] brackets when showing a list of
0
+ -- expressions, since we're going to use different brackets
0
+ -- depending on whether the list represents a sequence, set, or
0
+ showList [] = showString ""
0
+ showList (x:xs) = shows x . showl xs
0
+ showl (x:xs) = showChar ',' . shows x . showl xs