Proposal: Add default instances for Functor and Applicative

Maciej Marcin Piechotka uzytkownik2 at
Fri Sep 23 22:25:11 CEST 2011

The problem of backward compatibility have been the main obstacle
against adopting Functor f => (Pointed f =>?) => Applicative f => Monad

This proposition is to add following default instances[1]:

default fmap :: Applicative f => (a -> b) -> f a -> f b
f `fmap` m = pure f <*> m
default pure :: Monad f => a -> f a
pure = return
default (<*>) :: Monad f => f (a -> b) -> f a -> f b
(<*>) = liftM2 ($)

The proposition is intended as step towards implementing whole hierarchy
of Functor f => (Pointed f =>?) => Applicative f => Monad f[2]

Discussion period: 2 weeks


[1] It's using DefaultSuperclassInstances extentions:
[2] Trivial implementation is shown here:

I believe that in such case the Pointed instance comes at nearly zero
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the Libraries mailing list