Skip to content

Commit

Permalink
slides: changes to course 3 and 4
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Jan 17, 2023
1 parent 550a47e commit 554459a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
17 changes: 9 additions & 8 deletions slides/course-03.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,10 @@ show :: Show a => a -> String
</br>

```bash
:type (<)
(<) :: Ord a => a -> a -> Bool
map2 :: [a] -> (a -> b) -> [b]
```

- What is the type of `(<) 3`?
- What is `map2`? How would you explain it to a coworker?

--

Expand Down Expand Up @@ -340,20 +339,22 @@ To solve problems functionally:
- Recursion: divide a problem into smaller subproblems
- Fold: iterate over data, accumulate a value along the way

<!-- exdown-skip 6 7 -->
<!-- exdown-skip 1 3 4 -->
```hs
data Tree a = Node a [Tree a]

find :: (a -> Bool) -> Tree a -> Maybe a
find f t = undefined
data Tree a = ...

map :: (a -> b) -> Tree a -> Tree b
map f t = undefined

find :: (a -> Bool) -> Tree a -> Maybe a
find f t = undefined
```

???

```hs
data Tree a = Node a [Tree a] -- Discuss alternatives

treeFind :: (a -> Bool) -> Tree a -> Maybe a
treeFind f (Node x children) =
if f x then Just x
Expand Down
19 changes: 10 additions & 9 deletions slides/course-04.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,23 @@ Define:
```hs
instance Eq Bool where
(==) a b = undefined

instance Eq a => Eq (Maybe a) where
(==) a b = undefined
```

???

- Discuss `equals` and `hashCode` in Java
--

<!-- exdown-skip -->
<!-- exdown-skip 4 5 -->
```hs
instance Eq a => Eq (Maybe a) where
(==) _a _b = undefined

instance Eq a => Eq [a] where
(==) = undefined
(==) _xs _ys = undefined
```

???

- Discuss `equals` and `hashCode` in Java

```hs
instance Eq a => Eq [a] where -- Build bigger instances from smaller ones
(==) [] [] = True
Expand Down Expand Up @@ -359,7 +359,6 @@ class Functor f where
- What does `fmap` do?
- Give instances:
- `Maybe a`
- `Either a b`
- `[a]`

---
Expand Down Expand Up @@ -407,6 +406,8 @@ Typeclasses:

- Choose runtime behavior based on static types (/= dynamic dispatching)
- Leverage the compiler's generation capabilities
- Build APIs and features bottom up:
- from small values, to more structured values.

---

Expand Down

0 comments on commit 554459a

Please sign in to comment.