Skip to content

Commit a41e9fe

Browse files
committed
Update my answers in ch5
1 parent 0718715 commit a41e9fe

File tree

6 files changed

+17
-2
lines changed

6 files changed

+17
-2
lines changed

ch5/DetermineTheType.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{-# LANGUAGE NoMonomorphismRestriction #-}
2+
-- Toggle to see how the type of example changes
3+
4+
module DetermineTheType where
5+
6+
-- simple example
7+
example = 1

ch5/doesItCompile.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-- N.B. Yes = it squawks, No = it doesn't squawk i.e. it works
2+
13
-- 1
24
bigNum = (^) 5 $ 10
35
-- wahoo = bigNum $ 10

ch5/ex1.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Exercises: Type Matching
2+
13
1.
24

35
a) not :: Bool -> Bool ; c)

ch5/ex2.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Exercises: Type Arguments
2+
13
1. a)
24

35
let f :: a -> a -> a -> a; f = undefined

ch5/ex3.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
id :: a -> a
44
id x = x
55

6-
We cannot do anything to x because it's not constrained to anything.
6+
I don't know anything about x so all I can do is return it.
77

88
2. Given type a -> a -> a, we can define
99

@@ -25,4 +25,4 @@ snd x y = y
2525
There is only one possible implementation.
2626

2727
If we know more about a and b then the behaviour can change because we may be
28-
about to use more operations on them to return something different.
28+
able to use more operations on them to return something different.

ch5/ex4.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Exercises: Apply Yourself
2+
13
1.
24

35
myConcat :: [Char]

0 commit comments

Comments
 (0)