[Haskell-cafe] Parsec combinator like Prolog's cut operator?
andrewcoppin at btinternet.com
Wed Jun 30 17:14:25 EDT 2010
Ivan Lazar Miljenovic wrote:
> >From the Polyparse homepage (http://www.cs.york.ac.uk/fp/polyparse/):
> | If you are familiar with the Parsec library, then the key insight for
> | using PolyParse is that the two libraries' approach to backtracking
> | are the duals of each another. In Parsec, you must explicitly add a
> | try combinator at any location where backtracking might be
> | necessary. Users often find this a bit of a black art. In PolyParse by
> | contrast, all parsers are backtracking unless you explicitly add a
> | commit (or one of its variations). It is easy to tell where to add a
> | commit point, because you have already parsed enough of a data
> | structure to know that only one outcome is possible. For instance, if
> | you are parsing a Haskell value produced by 'show', then as soon as
> | you have parsed the initial constructor, you know that no other
> | constructor of that datatype is possible, so you can commit to
> | returning it.
Really? How interesting...
I've never actually heard of Polyparse. I'll have to check it out.
More information about the Haskell-Cafe