Proposal: Add default instances for Functor and Applicative

Maciej Marcin Piechotka uzytkownik2 at gmail.com
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
f.

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

Regards

[1] It's using DefaultSuperclassInstances extentions:
http://hackage.haskell.org/trac/ghc/wiki/DefaultSuperclassInstances
[2] Trivial implementation is shown here:
http://thread.gmane.org/gmane.comp.lang.haskell.libraries/16196

I believe that in such case the Pointed instance comes at nearly zero
cost.
-------------- 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: <http://www.haskell.org/pipermail/libraries/attachments/20110923/3c6012fb/attachment.pgp>


More information about the Libraries mailing list