-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter-5.hs
More file actions
52 lines (39 loc) · 712 Bytes
/
Copy pathchapter-5.hs
File metadata and controls
52 lines (39 loc) · 712 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
-- Chapter 5 exercises
-- Exercises - Type Matching
-- a - c
-- b - d
-- c - b
-- d - a
-- e - e
-- Exercises - Type Arguments
-- 1 - a
-- 2 - d
-- 3 - d
-- 4 - c
-- 5 - a
-- 6 - e
-- 7 - d
-- 8 - a
-- 9 - c
-- Exercises - Parametricity
-- 1 - Can't do anything here!
-- 2
f :: a -> a -> a
f x y = x
f x y = y
-- 3 - It has only one implementation and the behavior does not change when the
-- type of `a` or `b` change.
f' :: a -> b -> b
f' x y = y
-- Exercises - Apply Yourself
-- 1 - [Char] -> [Char]
-- 2 - Fractional a => a -> a
-- 3 - Int -> [Char]
-- 4 - Int -> Bool
-- 5 - Char -> Bool
-- Chapter exercises
-- 1 - a, b, c
-- 2 - a
-- 3 - b
-- 4 - c
-- Look at the file `determineTheType.hs`.