[Haskell-cafe] if-then-else as rebindable syntax (was Re: Why does Haskell have the if-then-else syntax?)

David Roundy droundy at darcs.net
Thu Jul 27 11:00:24 EDT 2006

On Thu, Jul 27, 2006 at 02:57:20PM +0200, Doaitse Swierstra wrote:
> On Jul 27, 2006, at 1:35 PM, Niklas Broberg wrote:
> >I would really like to see this implemented, and I don't think the
> >above is serious enough that we shouldn't. There may be some that
> >don't agree though. Speak up now, or forever hold your peace!

Me too, this sounds really cool!

> We alreday are at a stage where first year students trying to master  
> haskell get error messages like
> "Bool is not an instance of the class Num"
> if they accidently write 1 + True (or something equivalent, but less  
> obvious).

I think this is not a language issue so much as a compiler issue, and
I don't think it's a sound idea to limit the language or libraries
based on the existing poor error messages.  If the above gave a
message like

(+) requires an argument of class Num, but "True" is of type Bool,
which is not in class Num.

I don't think there would be a problem.  In general, I think classes
should be used more, rather than less, and if that means we need a SoC
project to improve the clarity of error messages, then that's what
needs to be done.  (I'll admit, I'm unlikely to do this...)

> If you want to mess around why not call the function "provided" or  
> something similar.

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.
David Roundy

More information about the Haskell-Cafe mailing list