[Haskell-cafe] All-fail case in asum

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Fri Jun 10 17:16:26 UTC 2016


On Fri, Jun 10, 2016 at 07:56:04PM +0300, Юрий Сыровецкий (Yuriy Syrovetskiy) wrote:
> I think, this Parser type is not perfectly monoidal, so in general asum and
> (<|>) are not interchangeable.

Please can you post an example showing that?  I am unable to replicate this
behaviour.

ghci> import Text.ParserCombinators.Parsec
ghci> import Data.Foldable

ghci> let ar = asum [space, space, fail "My fail"] :: Parser Char

ghci> runParser ar () "" "x"
Left (line 1, column 1):
unexpected "x"
expecting space
My fail

It seems that the custom fail is indeed picked up.  No hint of "error" here.

Tom


More information about the Haskell-Cafe mailing list