[Haskell-beginners] Infix operator and precedence

Patrick LeBoutillier patrick.leboutillier at gmail.com
Fri Dec 24 16:32:30 CET 2010


Hi,

I'm just messing around with infix operators, and I'm trying to
implement some kind of ternary if operator:

(??) :: Bool -> (Bool -> a) -> a
(??) = flip ($)

(?:) :: a -> a -> (Bool -> a)
t ?: f = \b -> if b then t else f

test b = b ?? ("IF" ?: "THEN")

I would like to get rid of the parentheses around the ("IF" ?: "THEN")
part, but I'm not familiar with the
use of theinfixr/infixl functions. I'm not sure which one to use in
this case and how exactly to use it.

Can anyone shed some light?


Thanks a lot,

Patrick

-- 
=====================
Patrick LeBoutillier
Rosemère, Québec, Canada



More information about the Beginners mailing list