-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chapter5.hs
79 lines (63 loc) · 1.08 KB
/
Chapter5.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
-- Fix it
-- 1
--module Sing where
--
--fstString :: [Char] -> [Char]
--fstString x = x ++ " in the rain"
--
--sndString :: [Char] -> [Char]
--sndString x = x ++ " over the rainbow"
--
--sing = if (x < y) then fstString x else sndString y
-- where x = "Singing"
-- y = "Somewhere"
--
---- Earlier Exercises
--r :: [a] -> [a]
--r a = a
--
--co :: (b -> c) -> (a -> b) -> a -> c
--co bToC aToB a = (bToC (aToB a))
--
--a :: (a -> c) -> a -> a
--a _ a = a
--
--a' :: (a -> b) -> a -> b
--a' aToB a = aToB a
module Arith3Broken where
main :: IO ()
main = do
print (1 + 2)
print 10
print (negate 1)
print ((+) 0 blah)
where blah = negate 1
f :: Int -> String
f = undefined
g :: String -> Char
g = undefined
h :: Int -> Char
h a = g (f a)
data A
data B
data C
q :: A -> B
q = undefined
w :: B -> C
w = undefined
e :: A -> C
e a = w (q a)
data X
data Y
data Z
xz :: X -> Z
xz = undefined
yz :: Y -> Z
yz = undefined
xform :: (X, Y) -> (Z, Z)
xform (x, y) = (xz x, yz y)
munge :: (x -> y)
-> (y -> (w, z))
-> x
-> w
munge xToY yToWZ x = fst (yToWZ (xToY x))