On Thu, Dec 15, 2011 at 1:23 AM, Gregory Crosswhite
<[email protected]> wrote:
>
> On Dec 15, 2011, at 3:36 PM, Antoine Latter wrote:
>
>> There are a lot of combinators you can build from (<|>) and empty that
>> go terribly wrong for Maybe and List but are still quite useful.
>>
>
> Yes, you *could* do that, but the whole point is that you shouldn't.
>  Typeclasses generally come with informal laws that must be obeyed.  If your
> instance does not obey those laws, then it should not be an instance.
>

I said 'combinators', not 'instances'. A lot of popular parsers
combinators can be written exclusively from (<|>) and empty, but make
little sense for List and Maybe, and may not even function properly.
The 'trifecta' package includes a nice reference:

http://hackage.haskell.org/packages/archive/trifecta/0.49.1/doc/html/Text-Trifecta-Parser-Combinators.html

See 'skipSome' through 'chainr1' - I wouldn't be surprised if most of
these lead to the same infinite loop behavior for Maybe as the stock
'many' and 'some' in base.

These sorts of functions are what Alternative is for.

Maybe I'm missing something fundamental here.

Antoine

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to