Proposal: Add Applicative instances for the remaining monads in base

Bas van Dijk v.dijk.bas at gmail.com
Fri Nov 11 17:49:36 CET 2011


Hello,

The only public monads in base that don't have Applicative instances
yet are: ReadP, ReadPrec and ArrowMonad. Because of the rule of least
surprise I would like to propose adding Applicative instances for
these monads.

Concretely I would like to propose adding the following to Control.Applicative:

instance Applicative ReadP where
    pure = return
    (<*>) = ap

instance Alternative ReadP where
    empty = mzero
    (<|>) = mplus

instance Applicative ReadPrec where
    pure = return
    (<*>) = ap

instance Alternative ReadPrec where
    empty = mzero
    (<|>) = mplus

instance ArrowApply a => Applicative (ArrowMonad a) where
    pure = return
    (<*>) = ap

And adding a Functor instance for ArrowMonad to Control.Arrow:

instance Arrow a => Functor (ArrowMonad a) where
    fmap f (ArrowMonad m) = ArrowMonad $ m >>> arr f

Discussion deadline: I don't think this is a controversial proposal
and so I don't expect objections. Can we bend the rules a bit and
shorten the discussion period so this can be integrated into the base
library that comes with the upcoming ghc-7.4?

Regards,

Bas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-Applicative-instances-for-all-public-monads.patch
Type: text/x-patch
Size: 2616 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/libraries/attachments/20111111/045846a4/attachment.bin>


More information about the Libraries mailing list