
27 Jul
2006
27 Jul
'06
11:52 a.m.
On 27/07/06, David Roundy
Or perhaps (?:) or something like that, which could be used infix to evoke the idea of C's e1 ? e2 : e3 syntax. "provided" to me is less clear than "cond" since it has other meanings, and isn't borrowed from any language that I'm familiar with, like "cond" is.
This has come up a few times on #haskell, and the consensus is that a tertiary (?:) operator isn't possible because of the deep specialness of (:). However, you can simulate it pretty well: infixr 1 ? (?) :: Bool -> (a, a) -> a True ? (t, _) = t False ? (_, t) = t Then you call it like: length "hello" > 4 ? ("yes it is!", "afraid not") -- -David House, dmhouse@gmail.com