Would it be theoretically possible/convenient to be able to put boilerplate like this in class definitions?
On Thu, Jul 21, 2011 at 8:31 AM, Ivan Lazar MiljenovicNote that even if we had "class Applicative m => Monad m where ...",
<ivan.miljenovic@gmail.com> wrote:
> Well, for fmap vs liftM, you have that liftM is automatically defined
> for you rather than needing to make the Functor instance, so if you're
> quickly defining a Monad for internal use then you can just use liftM,
> etc. without needing to also make Functor and Applicative instances
> (note that AFAIK, return and pure are the same thing, in that return
> isn't automatically defined like liftM is).
we could say
data X a = ...
instance Functor X where
fmap = liftM
instance Applicative X where
pure = return
(<*>) = ap
instance Monad X where
return = ...
x >>= f = ...
So you just need five more lines of boilerplate to define both Functor
and Applicative.
Cheers,
--
Felipe.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe