Applicative and parsec3

Antoine Latter aslatter at gmail.com
Fri Jan 28 18:04:02 CET 2011


On Thu, Jan 27, 2011 at 4:29 AM, Christian Maeder
<Christian.Maeder at dfki.de> wrote:
> Am 27.01.2011 07:16, schrieb Kazu Yamamoto (山本和彦):
>> Hello,
>>
>> I'm using parsec3 with the applicative style. Since the functions in
>> Control.Applicative and parsec3 conflicts, I need to use the "hiding"
>> keyword as follows:
>>
>>       import Control.Applicative hiding (many,optional,(<|>))
>>       import Text.Parsec
>
> Another problem:
>
> Control.Applicative.optional corresponds to
> Text.Parsec.Combinator.optionMaybe whereas
> Text.Parsec.Combinator.optional returns "()".
>
>> This is inconvenient for me. I would like to use them as follows:
>>
>>       import Control.Applicative
>>       import Text.Parsec
>>
>> Christian, the maintainer of parsec3, told me that it is possible to
>> use the functions of Control.Applicative in parsec3 instead of
>> implementing its own functions. But (<|>) of parsec3 is "infixr 1"
>> while that of Control.Applicative is "infixl 3".  This may be an
>> issue.
>>
>> Any ideas to solve this issue?
>
> If we are lucky removing the "infixr 1 <|>" operator does not break too
> much existing code, because the combination with "infixl 1 >>" needs
> always brackets, currently. (But a changed interpretation might be hard
> to notice.)
>
> However, using "a >> b <|> c" would then no longer be an error and
> interpreted as "a >> (b <|> c)", whereas  "a *> b <|> c" would be "(a *>
> b) <|> c".
>

I think the change would be worth it, even if painful for existing users.

I'm less sure how to go forward for the different "optional" combinators.

I would want to port over 'many' to be the one exported from
Applicative as well.

Antoine

> Christian
>
>>
>> --Kazu
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>



More information about the Libraries mailing list