incorrect parsing

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Thu Jan 3 12:10:56 EST 2002


This program:

    module Main where
    f = map (++"a"++"b")
    g = map ("a"++"b"++)
    main = do print (f ["x","y","z"])
              print (g ["x","y","z"])

gives the following error messages with ghc (versions 4.08.2 and 5.02):

    plusplus.hs:3:
        The operator `++' [infixr 5] of a section
            must have lower precedence than the operand `++' [infixr 5]
            In the section: `(++ ("a" ++ "b"))'

    plusplus.hs:4:
        The operator `++' [infixr 5] of a section
            must have lower precedence than the operand `++' [infixr 5]
            In the section: `(("a" ++ "b") ++)'

I believe this is the wrong behaviour - the first (right) section is
perfectly valid Haskell'98 because the operator is right associative.
Hugs, hbc, and nhc98 all accept it.  Check also section 3.5 (p.17)
of the Report.

The second (left) section is indeed incorrect, again because the
operator is right associative.

Regards,
    Malcolm




More information about the Glasgow-haskell-bugs mailing list