[Haskell-beginners] Infix operator and precedence

Isaac Dupree ml at isaac.cedarswampstudios.org
Fri Dec 24 17:46:15 CET 2010


On 12/24/10 10:32, Patrick LeBoutillier wrote:
> test b = b ?? ("IF" ?: "THEN")

This is right-associative. This binds more tightly in the ?:.  Either is 
sufficent to make your infix work:

infixr 1 ??
infixr 1 ?:

or

infix 1 ??
infix 2 ?:

(I picked low numbers 1 and 2 arbitrarily and because C's ?: operator is 
also rather low precedence.  See what happens if you do + and * inside 
your ternary-if if you use infix numbers like 8 or 9.)



More information about the Beginners mailing list