-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab3.hs
More file actions
34 lines (25 loc) · 785 Bytes
/
Lab3.hs
File metadata and controls
34 lines (25 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Lab3 where
import Data.Char (ord, toLower)
import Tree
class Abs a where
-- | Returns True the two elements are abs-equal
(=||=) :: a -> a -> Bool
-- | Get the integral "magnitude" of this element
magnitude :: a -> Int
instance Abs Int where
x =||= y = abs x == abs y
magnitude = abs
instance Abs Char where
x =||= y = toLower x == toLower y
magnitude = ord . toLower
cmp :: {- Task 0 -}
cmp x y = error "Task 0"
cmpMagnitude :: {- Task 0 -}
cmpMagnitude x y = error "Task 0"
-- | Implemented the Abs instance definition for
-- arbitrary Tree's. A tree is equal (=||=) to another if it is
-- structually equivalent and all the leaf and node values are equal
-- (=||=).
instance Abs (Tree a) where
(=||=) = error "Task 1"
magnitude = error "Task 1"