[Haskell-beginners] basic Functor, Applicative and Monad instances

Rein Henrichs rein.henrichs at gmail.com
Thu Jul 16 20:26:19 UTC 2015


This would all be much easier with pattern matching. For example:

instance Functor Val where
  fmap f (Val x) = Val (f x)

instance Applicative Val where
  pure = Val
  Val f <*> Val x = Val (f x)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150716/a4723d69/attachment.html>


More information about the Beginners mailing list