parent
8945191a8c
commit
ae9e3118df
3 changed files with 48 additions and 5 deletions
@ -1,2 +1,19 @@ |
||||
# Exercises: Library Functions |
||||
# 20.5 Some basic derived operations |
||||
|
||||
Why does `fmap length Just [1, 2, 3]` return 1? |
||||
|
||||
```haskell |
||||
fmap :: Functor f => (a -> b) -> f a -> f b |
||||
length :: Foldable t => t a -> Int |
||||
Just :: a -> Maybe a |
||||
|
||||
fmap length :: (Foldable t, Functor f) => f (t a) -> f Int |
||||
-- notice that the next argument given is an f (t a) and since |
||||
-- (->) is also a functor f is ((->) a) and (t a) is Maybe a |
||||
-- this also makes f Int an (a -> Int) |
||||
fmap length Just :: a -> Int |
||||
``` |
||||
|
||||
## Exercises: Library Functions |
||||
|
||||
see src/functions.h |
Loading…
Reference in new issue