Lecture 8: Maybe Monad

*Exercise 8.1

Implement the following function in terms of map and mapMaybe:

mapListMaybe :: (a -> b) -> [Maybe a] -> [Maybe b]

Exercise 8.2

Implement the following function in terms of map and mapMaybe:

mapMaybeList :: (a -> b) -> Maybe [a] -> Maybe [b]

*Exercise 8.3

Implement the following function in terms of andThenMaybe; you may not use pattern matching directly:

joinMaybe :: Maybe (Maybe a) -> Maybe a

Exercise 8.4

Re-implement the following function directly (using pattern matching, not using andThenMaybe):

joinMaybe :: Maybe (Maybe a) -> Maybe a

And then implement andThenMaybe in terms of joinMaybe and other *Maybe functions (you may not use pattern matching directly).