Proposal: Applicative => Monad: Call for consensus
iavor.diatchki at gmail.com
Tue Jan 4 19:06:07 CET 2011
I am also skeptical about the need to add "join" to the monad class. My
reasoning is that I doubt that one can define an instance where "join" and
"bind" perform differently, so we are just adding overhead, both cognitive
(because the Monad class get more complex) and resource-wise (because
dictionaries need to carry an additional method).
Note that if you find "join" easier to define then "bind" (which I'd be
surprised for any monad other then lists), you can still do just that:
define "join", and then define "bind" in the usual way.
In terms of the "symmetry" that Tyson mention, this is how I like to think
about the three applications:
fmap :: (a -> b) -> f a -> f b
(<*>) :: f (a -> b) -> f a -> f b
(=<<) :: (a -> f b) -> f a -> f b
So really, (=<<) seems the most symmetric to me, but I don't think that the
pain of changing the class to use (=<<) would really be justified.
I completely agree with Ian that it'd be better to get all changes in a
single proposal, so that we only need to fix things once, so let's at least
drop the duplicated methods.
On Tue, Jan 4, 2011 at 7:51 AM, Tyson Whitehead <twhitehead at gmail.com>wrote:
> On January 4, 2011 07:25:36 Ian Lynagh wrote:
> > Have you got an example of a Monad for which you'd want to define join
> > but not (>>=)?
> > > (>>) :: forall a b. m a -> m b -> m b
> > > (>>) = (*>)
> > >
> > > return :: a -> m a
> > > return = pure
> > >
> > > fail :: String -> m a
> > > fail s = error s
> > >
> > > 2) Make 'join' a method of Monad.
> > Why?
> It seems to me that while join is more of a value transformer as apposed to
> flow combining operator, which makes it fit in better with the rest
> That is,
> (<*>) :: f (a -> b) -> f a -> f b -- (<*>) f -- transforms f
> join :: f (f a) -> f a -- join y -- transforms y
> return :: a -> f a -- return x -- transforms x
> Cheers! -Tyson
> Libraries mailing list
> Libraries at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries