thoughtbot / maybe_haskell

Programming without Null
http://maybe-haskell.com
Other
80 stars 4 forks source link

Functor section declares a class, should be instance #79

Closed pbrisbin closed 7 years ago

pbrisbin commented 7 years ago

Functor's examples, page 13.

class Functor Maybe where
    fmap = whenJust

class Functor Maybe where
    fmap _ Nothing = Nothing
    fmap f (Just x) = Just (f x)

You're supposed to create instances of the typeclass Functor for Maybe:

instance Functor Maybe where
    fmap = whenJust

instance Functor Maybe where
    fmap _ Nothing = Nothing
    fmap f (Just x) = Just (f x)

Reported via email by Agustín Camino.

pbrisbin commented 7 years ago

This appears to have been reported on an older version of the book. This was fixed in 3a6b98c00d78f93c8dde62f5ef2d3eb3968c9110, well before release.