
28 Dec
2007
28 Dec
'07
7:03 p.m.
Hi!
On Dec 29, 2007 12:13 AM, Evan Laforge
Maybe you could use view patterns?
foo (regex "(.*);(.*);(.*)") -> [c1, c2, c3] = ...
Oh. Beautiful. :-)
Parser combinators basically provide generalized regexes, and they all take lists of arbitrary tokens rather than just Chars. I've written a simple combinator library before that dispenses with all the monadic goodness in favor of a group combinator and returning [Either [tok] [tok]], which sort of gives parsers a simpler regexy flavor (Left is "out of group chunk" and Right is "in group chunk").
foo (match (group any `sepBy` char ';') -> [c1, c2, c3]) = ...
Ah. Is this accessible somewhere? Mitar