
Of course, but I want the *perfect* solution.
I think, this Parser type is not perfectly monoidal, so in general asum and
(<|>) are not interchangeable.
On 10 Jun 2016 19:51, "Erik Hesselink"
Disregarding is `asum` should be changed, perhaps you could fix your issue by doing:
myParser = asum [tryA, tryB] <|> fail "input must be either A or B"
Erik
On 10 June 2016 at 16:37, Юрий Сыровецкий (Yuriy Syrovetskiy)
wrote: Hello
I want to define some parser such way:
myParser = tryA <|> tryB <|> fail "input must be either A or B"
It works. But then I want to rewrite it with asum:
myParser = asum [tryA, tryB, fail "must be A or B"]
It works, but the wrong way. Instead of my error it writes "empty". Just "empty".
It is so because in base library
asum = foldr (<|>) empty
What if it was defined
asum [] = empty asum [x:xs] = x <|> asum xs
It would help me with my parser. But what can this break? Why isn't this done yet?
-- Yuriy Syrovetskiy, http://cblp.su _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe