logoalt Hacker News

taolson • yesterday at 11:29 PM • 1 reply • view on HN

That may be true for functions which operate on a generic Monad typeclass, but typeclasses (Higher kinded types) aren't required to implement concrete Functor / Applicative / Monad instances for a particular type, e.g. Maybe:

    fmap f Nothing = Nothing
    fmap f (Just x) = Just (f x)

    pure x = Just x

    Nothing >>= f = Nothing
    Just x >>= f = f x

Replies

fn-mote • today at 12:56 AM

When people say they don’t understand Monad, my first assumption is that they are wearing their ignorance as a badge of honor.

Otherwise memorize a little bit and dispose of the mystery. It’s not that far out.