-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInhabitants.hs
82 lines (56 loc) · 1.19 KB
/
Inhabitants.hs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
module Inhabitants where
-- Define *convergent* (not bottom-ish) inhabitants
-- of the following types.
-- For each type, if you can define more than one
-- inhabitant, define a few of them, using primes
-- to name the other inhabitants, for example:
-- f, f', f'', f''', f'''', etc.
cI :: a -> a
cI x = x
cK :: a -> b -> a
cK x y = x
cS :: (a -> b -> c) -> (a -> b) -> (a -> c)
cS f g x = f x (g x)
cB :: (b -> c) -> ((a -> b) -> (a -> c))
cB f g = f . g
cW :: (a -> (a -> b)) -> (a -> b)
cW f x = f x x
pL :: ((a -> b) -> a) -> a
pL f = undefined
-- boo
p1 :: (a,b) -> a
p1 (x,y) = x
p2 :: (a,b) -> b
p2 (x,y) = y
p3 :: (a,b) -> (b,a)
p3 (x,y) = (y,x)
p4 :: Either a b -> b
p4 = undefined
p5 :: Either a b -> [a]
p5 = undefined
p6 :: Either a b -> (a,b)
p6 = undefined
p7 :: (a,b) -> Either a b
p7 = undefined
p8 :: (a,b) -> Either a b
p8 = undefined
p9 :: a -> b -> (a,a,b)
p9 = undefined
q1 :: a -> a -> a
q1 = undefined
q2 :: (a,a) -> (a,a)
q2 = undefined
q3 :: Either (a,b) (a,c) -> (a, Either b c)
q3 = undefined
l1 :: [a]
l1 = undefined
l2 :: [[a]]
l2 = undefined
l3 :: [a] -> [a]
l3 = undefined
l4 :: a -> [a]
l4 = undefined
l5 :: [a] -> a
l5 = undefined
l6 :: a -> [[a]]
l6 = undefined