You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
507 B
19 lines
507 B
# 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 |