[Haskell-cafe] Is it acceptable if Applicative behave not like a Monad
nikita.y.volkov at mail.ru
Thu Apr 30 17:32:54 UTC 2015
I'm afraid I have to disagree with Adam as well. Recently I've triggered a
prolonged discussion on exactly the subject (
https://github.com/ekmett/either/pull/38). Being originally convinced that
the instances can behave however it fits, I think I've been over-persuaded
in the end.
Shortly speaking, while I can't say I like it, the rule seems to be that
`<*>` should produce the same side effects as Monad's `ap`.
The most convincing argument I've seen so far against the two digressing is
that it can cause unexpected behaviour of the "do" notation (
https://github.com/ekmett/either/pull/38#issuecomment-95695814), but you'll
find plenty of other arguments in the discussion as well.
2015-04-30 19:07 GMT+03:00 Kim-Ee Yeoh <ky3 at atamo.com>:
> On Thu, Apr 30, 2015 at 10:49 PM, Adam Bergmark <adam at bergmark.nl> wrote:
>> Yes it's okay and sometimes expected for them not not behave the same,
>> but see e.g. haxl and ApplicativeDo.
> This is a value of okay I've never seen before.
>> For example, the applicative version may run foo and bar in parallell.
>> But using monad they run sequentially.
> What if pure weren't a perfect synonym for return?
> What if the methods of the semigroup instance didn't match those of the
> The mind boggles at the confusion that would result.
> Such cases typically call for newtypes to sort out the effect classes.
> -- Kim-Ee
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe