Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Commit 84040589 authored by pm3g19's avatar pm3g19
Browse files

Added show definition for predeffunc

parent 1fae3284
......@@ -11,10 +11,27 @@ data PredefFunc = XProduct | XXProduct | IsEqual | IsNotEqual | Plus --operators
| Map | Filter
| RecordIndex -- [] operator
| RecordSelect
| IsEmpty | NotEmpty | Contains -- string functions
| And
| Or
deriving (Show, Eq)
| IsEmpty | NotEmpty | Contains -- string functions
| Length
| Not
| BooleanFunc (Bool -> Bool -> Bool)
--TODO others:reverse
instance Show PredefFunc where
show XProduct = "XProduct"
show XXProduct = "XXProduct"
show IsEqual = "IsEqual"
show IsNotEqual = "IsNotEqual"
show Plus = "Plus"
show Map = "Map"
show Filter = "Filter"
show RecordIndex = "RecordIndex"
show RecordSelect = "RecordSelect"
show IsEmpty = "IsEmpty"
show NotEmpty = "NotEmpty"
show Contains = "Contains"
show Length = "Length"
show Not = "Not"
show (BooleanFunc _) = "BooleanFunc"
--n.b. these definitions do not enforce type checking! The use of any function or operator will be associated with a FuncCall.
......@@ -36,8 +53,18 @@ data Expr = Control Expr [Expr] -- result of last computation, sequence of instr
| Int Int
| String String
| Boolean Bool
| Let SymbolName Expr
| Let Bool SymbolName Expr
-- | Nat Int
deriving (Show, Eq)
deriving (Show)
booleanExpr func e1 e2 = FuncCall (PredefFunc $ BooleanFunc func) [] [e1,e2]
instance Eq Expr where
--(Record r1) == (Record r2) = and (zipWith (==) r1 r2)
--(String s1) == (String s2) = and (zipWith (==) s1 s2)
(Record r1) == (Record r2) = r1 == r2;
(String s1) == (String s2) = s1 == s2
(Boolean b1) == (Boolean b2) = b1 == b2
(Int v1) == (Int v2) = v1 == v2
_ == _ = error "Comparison of incompatible types"
data Parameter = NamedParam SymbolName | TupleMatch [SymbolName]
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment