[Haskell-cafe] Is it acceptable if Applicative behave not like a Monad

Andrew Gibiansky andrew.gibiansky at gmail.com
Fri May 1 05:11:49 UTC 2015

Why can't the library provide a `newtype`, one which supports `Applicative`
*and* `Monad` interfaces (where the applicative and monadic interfaces
match), and an un-newtyped variant that only supports `Applicaative`, as
well as conversion functions?

I think this would be clearer, as it would force you to switch into
"Monad"-mode purposefully, and the documentation on the conversion function
can make very clear what is going on.

I agree that, now that we have AMP, applicative and monadic interfaces
absolutely *should* match, and that it should be considered an error for
them not to; semantically different interfaces can be provided with

-- Andrew

On Thu, Apr 30, 2015 at 6:46 PM, Omari Norman <omari at smileystation.com>

> On Thu, Apr 30, 2015 at 1:32 PM, Nikita Volkov <nikita.y.volkov at mail.ru>
> wrote:
>> 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`.
> One example of a library where the Applicative and Monad instances
> mismatch is uu-parsinglib.
> http://stackoverflow.com/questions/18275123/cannot-compute-minimal-length-of-a-parser-uu-parsinglib-in-haskell/18292328#18292328
> There's a good reason the library is this way but the behavior can be
> rather startling.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150430/9fcee651/attachment.html>

More information about the Haskell-Cafe mailing list