Skip to content

Commit 5af714f

Browse files
committed
Change Operation's number type
1 parent 62964cc commit 5af714f

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

slides/Course03.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ lastv v1 v2 =
4949
(Beta, SemVer _ _ _) -> v2
5050
(SemVer x1 _ _, SemVer x2 _ _) | x1 < x2 -> v2
5151
(SemVer x1 y1 _, SemVer x2 y2 _) | x1 == x2 && y1 < y2 -> v2
52-
_ -> error "I'm too lazy"
52+
_ -> error "TODO"
5353

5454
data Sign = Negative | Zero | Positive
5555

@@ -89,14 +89,13 @@ instance Functor Tree where
8989
fmap f (Node x children) = Node (f x) (map (fmap f) children)
9090

9191

92-
-- | 'Word16' is a zero or positive number
93-
data Operation = Debit Word16 | Credit Word16
92+
data Operation = Debit Int | Credit Int
9493

9594

9695
wordCount :: [[String]] -> Int
9796
wordCount files = foldr (\words soFar -> (length words) + soFar) 0 files
9897

99-
balance' :: [Operation] -> Word16
98+
balance' :: [Operation] -> Int
10099
balance' = foldr (\op soFar -> toInt op + soFar) 0
101100
where
102101
toInt = \case Debit x -> -x; Credit x -> x

slides/course-03.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ instance Functor Tree where
287287
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
288288
```
289289

290-
<!-- exdown-skip 1 2 7 8 -->
290+
<!-- exdown-skip 1 2 6 7 -->
291291
```hs
292292
wordCount :: [[String]] -> Int
293293
wordCount files = undefined

0 commit comments

Comments
 (0)