Proposal: Applicative => Monad: Call for consensus
wren ng thornton
wren at freegeek.org
Tue Jan 4 03:58:03 CET 2011
On 1/3/11 7:22 PM, Isaac Dupree wrote:
> On 01/03/11 17:30, Bas van Dijk wrote:
>> The patch for base makes a few changes:
>> 1) Make Applicative a superclass of Monad. So the new hierarchy becomes:
>> 2) Make 'join' a method of Monad.
>> class Applicative m => Monad m where
>> (>>) :: forall a b. m a -> m b -> m b
>> (>>) = (*>)
> The former/current default definition of (>>) was based on (>>=), not
> (*>) (which if itself is undefined, itself defaults to (fmap (const id)
> a <*> b). That's a change.
Yes, that is a change.
> You also added defaults for most of the Monad methods, though they're
> obvious and I approve. The (>>) default might have worse performance
> than the previous default though?
Nope. Since (*>) is a class method it can be given the most efficient
implementation possible for the given type. Since (>>) is logically the
same function, then it should default to (*>) so that the efficient
implementation doesn't need to be duplicated. In the event that neither
is defined explicitly, then they will both default to the same
definition as pre-patch.
More information about the Libraries