[Haskell-cafe] Parsing unordered parameter list with Parsec

Will Newton will.newton at gmail.com
Thu Apr 5 10:50:26 EDT 2007


Hi all,

I'm new to Haskell and trying to do some parsing with Parsec. It's
been extremely good so far. I have run into a problem I can't seem to
see the solution to though. I hope someone on the list can help me
out!

I have a command with a parameter list like this:

CMD PARAM1 foo PARAM2 100 PARAM3 200

Which is easy enough to parse, but it turns out the grammar is not
particularly well defined, and it's considered acceptable to swap
parameter order round pretty much arbitrarily. Is there a simple way
to handle this? I would like to only allow one of each parameter, some
parameters may also be optional.

It feels like I might have to write my own combinator to do this but
I'm not sure I'm quite ready of that yet!

Thanks,


More information about the Haskell-Cafe mailing list