[Haskell-cafe] [Haskell] ANNOUNCE: incremental-parser library package

Mario Blažević mblazevic at stilo.com
Tue Mar 22 20:02:38 CET 2011

2011/3/22 Philippa Cowderoy <postmaster at flippac.org>

> This is what newtypes are for, no?

I did not think of that approach. I'm not sure how well it would work out,
but it would solve another problem I have, which is the duplication of
combinators many, some, and optional. Each of these could exist in two
forms, the lazy one and the greedy one, and the only difference is the
underlying choice combinator, (<|>) vs. (<<|>).

I'm not aware of any other parsing library taking this road, though, and
there must be a good reason. I'll try and see.

> 2011/3/22 Mario Blažević <mblazevic at stilo.com>
>>  This seems very interesting. One question:
>>> > The MonadPlus and the Alternative instance differ: the former's mplus
>>> > combinator equals the asymmetric <<|> choice.
>>> Why?
>>     Good question. Basically, I see MonadPlus as a union of Monad and
>> Alternative. The class should not exist at all. But as long as it does, I
>> figured I should provide an instance, and I made it different from the
>> Monoid+Alternative combination because otherwise it would be useless. My
>> second choice would be to remove the instance completely.
> I have to admit I really do not like having Applicative and MonadPlus with
> different behavior. Yes, one is redundant, but that is more an artifact of
> language evolution, than an intentional opportunity for diverging behavior.
> Every library I am aware of to date, save of course this one, has
> maintained their compatibility.
> If the instance for Alternative satisfies the underspecified MonadPlus
> laws, I'd just as soon have the 'useless redundant' instance. The power of
> MonadPlus is in the combinators that are built on top of it. Not in the
> primitives themselves.
> If the Alternative instance would not be a legal MonadPlus instance, then
> I'd feel much less queasy with your second scenario, and it simply removed.
> -Edward
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110322/4ba48ecd/attachment.htm>

More information about the Haskell-Cafe mailing list