Refactoring to Monads, Applicatives and Functors

It takes a bit of practice to get used to using Functors, Applicatives and Monads so here are some common patterns I have found that are more succinct when refactored. Hopefully it will help speeding up the journey to becoming a Functor ninja. Nested Maybes If you have a series of nested case statements on Maybes : nestedMaybePre :: Maybe Int -> Maybe Int nestedMaybePre maybe = case maybe of Nothing -> Nothing Just value -> case evenThing value of Nothing -> Nothing Just num -> Just num Since Maybe is a monad, you can instead chain them using bind (>>=) : »