Discussion: Arities of <*> and *> for Monad instances
David Feuer
david.feuer at gmail.com
Sun Nov 2 09:29:19 UTC 2014
http://hackage.haskell.org/package/base-4.7.0.1/docs/Control-Applicative.html
says that
The other methods have the following default definitions,
which may be overridden with equivalent specialized
implementations:
u *> v = pure (const id) <*> u <*> v
and
If f is also a Monad, it should satisfy
...
(<*>) = ap
The (potential) trouble is that these have higher arities than is always
natural. For example, it would seem reasonable to say
(<*>) Just f = fmap f
(<*>) Nothing = const Nothing
and to replace the default definition of (*>) like so:
(*>) a1 = (<*>) (id <$ a1)
but these are not strictly equivalent because they have arity 1 instead of
arity 2. Would such definitions be be better in some cases? If so, should
we weaken the rules a bit?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141102/1396abdd/attachment.html>
More information about the Libraries
mailing list