[Haskell-cafe] if-then-else as rebindable syntax

Henning Thielemann lemming at henning-thielemann.de
Thu Jul 27 11:32:10 EDT 2006


On Thu, 27 Jul 2006, Niklas Broberg wrote:

> Also, is cond the best name for the suggested function? If we don't
> expect anyone to really use it without the sugar, we could name it
> whatever weird thing so as to break as few existing programs as
> possible. It would make explicit import a bit more akward though. But
> I suspect that if this function did exist in the Prelude, people would
> start using it a lot.

That's true, I would like to use it. I plead for adding it to Prelude, 
whether the if-syntax becomes rebindable or not. I like to use (zipWith 
cond) for composing two lists depending on a key, or (uncurry . cond) 
as a choice between fst and snd, or the already mentioned 'select' command 
(foldr (uncurry cond)).

> Does anyone have any better suggestions, or is cond the name of the day?

 I like the similarity to "if".
 However if_ or if' are too un-preludish. :-)
 ifElseThen is probably too long.
 'cond' is acceptable. 'provided' too.


More information about the Haskell-Cafe mailing list