Fergus Henderson writes:
 > Hi,
 > 
 > Is the following legal Haskell?
 > 
 > > infixr 0 `foo`
 > > infixr 0 `bar`
 > > 
 > > x `foo` y = "foo(" ++ x ++ "," ++ y ++ ")"
 > > x `bar` y = "bar(" ++ x ++ "," ++ y ++ ")"
 > > dubious a b c = a `foo` b `bar` c
 > 
 > According to the grammar in the Haskell report, I don't think it is.
 > However, ghc-0.24 (ancient, I know) and Hugs 1.3 both accept it without
 > complaint.

The report says (pg 13):

Consecutive unparenthesised operators with the same precedence must
both be either left or right associative to avoid a syntax error.

I think, since you have two.... which are both right associative, that
it is fine.

(However, making the lower infixr an infixl should produce a syntax 
error.  This however does not seem to be the case for hbc)

Jon



Reply via email to