Is there a built-in or parser in the Parsec library?
I'm looking for a parser that will try to use the first parser, and will return Left a
if it succeeds, or if it doesn't work, try the second parser and return Right b
. In other words, something with a signature:
Parser a -> Parser b -> Parser (Either a b)
Where, for example, type Parser a = P.Parsec String () a
It's not particularly hard to implement this yourself:
parseEither pa pb = (Left <$> pa) <|> (Right <$> pb)
But it seems to be such a useful and trivial construct that I was wondering if something like this already exists in the Parsec library.
+3
Gal
source
to share
No one has answered this question yet
See similar questions:
five
or similar:
sixteen
6
five
4
3
3
2
2
0
0