
On Thu, Dec 15, 2011 at 1:40 AM, Antoine Latter
On Thu, Dec 15, 2011 at 1:23 AM, Gregory Crosswhite
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.
To clarify - I dropped Greg's sentence "Incidentally, exactly what use cases do you have in mind?", which is most of what I was addressing in my previous email.
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-Tr...
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