-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathch6.hs
More file actions
60 lines (40 loc) · 1.19 KB
/
ch6.hs
File metadata and controls
60 lines (40 loc) · 1.19 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module Ch6 where
import Data.List
data TisAnInteger = TisAn Integer
instance Eq TisAnInteger where
(==) (TisAn i) (TisAn i') = i==i'
data TowIntegers = Two Integer Integer
instance Eq TowIntegers where
(==) (Two i j) (Two i' j') = i==i' && j==j'
data StringInt = TisAnInteger Int
| TisAString String
instance Eq StringInt where
(==) (TisAnInteger i) (TisAnInteger i') = i==i'
(==) (TisAString s) (TisAString s') = s==s'
(==) _ _ = False
data Tuple a b = Tuple a b
instance (Eq a, Eq b) => Eq (Tuple a b) where
(==) (Tuple x y) (Tuple x' y') = x==x' && y==y'
data EitherOr a b = Hello a
| Bye b
instance (Eq a, Eq b) => Eq (EitherOr a b) where
(==) (Hello x) (Hello x') = x==x'
(==) (Bye y) (Bye y') = y==y'
(==) _ _ = False
i :: RealFrac a => a
i = 1.0
freud :: a -> a
freud x = x
myX = 1 :: Int
sigmund :: Int -> Int
sigmund x = myX
jung :: Ord a => [a] -> a
jung xs = head (sort xs)
mySort :: [Char] -> [Char]
mySort = sort
signifier :: [Char] -> Char
signifier xs = head (mySort xs)
arith :: Num b => (a -> b) -> Integer -> a -> b
arith f x y = (f y) + fromInteger x
chk :: Eq b => (a -> b) -> a -> b -> Bool
chk f x y = (f x) == y