[Haskell-cafe] Re: Why does Haskell have the if-then-else syntax?

2006-08-16 Thread Benjamin Franksen
Mike Gunter wrote:
I had hoped the History of Haskell paper would answer a question
I've pondered for some time: why does Haskell have the if-then-else
syntax?  The paper doesn't address this.  What's the story?

For what it's worth, I have been asking myself the same question several
times. If/then/else syntax could be replaced by a regular (lazy) function
without any noticeable loss. Almost every time I use if/then/else I end up
changing it to a case expression on teh underlying data (which is almost
never Bool); the only exception being simple one liners, and for those a
function would be even more concise.

IMHO, the next standardized version of Haskell, however named, should
abandon the special if/then/else syntax so we'll have at least /one/ item
where the language becomes smaller and simpler.

Remember: Perfection is reached not when there is nothing more to add, but
rather when there is nothing more to take away.

On another note, I remember reading a paper proposing to generalize
if/then/else to arbitrary (so-called) dist-fix operators, using something
like partial backquoting, as in

`if condition `then` true_branch `else` false_branch fi`

Can't remember the exact title of the paper, nor the details, but it was
something to do with adding macros to Haskell.

Cheers,
Ben

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Why does Haskell have the if-then-else syntax?

2006-08-16 Thread ajb
G'day all.

Quoting Benjamin Franksen [EMAIL PROTECTED]:

 For what it's worth, I have been asking myself the same question several
 times. If/then/else syntax could be replaced by a regular (lazy) function
 without any noticeable loss.

I believe that if-then-else cannot be replaced by a regular function
for the same reason that regular function application and ($) are not
identical.  The loss may not be noticeable, but it's still a loss.

It could be replaced by a case-switch-on-Bool, though.

 IMHO, the next standardized version of Haskell, however named, should
 abandon the special if/then/else syntax so we'll have at least /one/ item
 where the language becomes smaller and simpler.

The de facto Haskell philosophy, if you read the history paper, is to
have a small core language with a lot of syntactic sugar.  The syntactic
sugar is specified by translation to the core language.

The small core ensures that Haskell remains simple.  If you discount
changes in the type system, the Haskell core language is as simple now
as it was in 1989.

 Remember: Perfection is reached not when there is nothing more to add, but
 rather when there is nothing more to take away.

Perfection is asymptotically approached when arbitrary restrictions are
removed and special cases are dumped in favour of general, theoretically
sound, principles.  Perfection will never be reached in a practical
programming language, but it may be asymptotically approached.

Cheers,
Andrew Bromage
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Why does Haskell have the if-then-else syntax?

2006-07-27 Thread Stefan Monnier
 Confusingly,

 if c
 then t
 else f

 Also works, although no-one really knows why.

Actually, it doesn't work inside a `do' layout,


Stefan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Why does Haskell have the if-then-else syntax?

2006-07-26 Thread Dan Doel

On 7/26/06, Donn Cave [EMAIL PROTECTED] wrote:

That looks to me like a different way to spell if then else, but maybe
that's the answer to the question - conceptually, for every then there
really is an else, however you spell it, and only in a procedural language
does it make any sense to leave it implicit.  The exception that proves the
rule is else return () -, e.g.,


...


Strictly speaking that generalizes to any functional context where a generic
value can be assigned to the else clause, but there don't tend to be that
many other such contexts.  Does that answer the question?


I believe his question was why if-then-else is syntax, rather than the
function he gave. Since haskell is non-strict, it doesn't need to be
implemented as syntax (unlike, say, scheme, where it needs to be a
special form/macro to avoid executing both branches).

I imagine the answer is that having the syntax for it looks nicer/is
clearer. if a b c could be more cryptic than if a then b else c
for some values of a, b and c.

-- Dan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Why does Haskell have the if-then-else syntax?

2006-07-26 Thread Sebastian Sylvan

On 7/27/06, Dan Doel [EMAIL PROTECTED] wrote:

On 7/26/06, Donn Cave [EMAIL PROTECTED] wrote:
 That looks to me like a different way to spell if then else, but maybe
 that's the answer to the question - conceptually, for every then there
 really is an else, however you spell it, and only in a procedural language
 does it make any sense to leave it implicit.  The exception that proves the
 rule is else return () -, e.g.,

...

 Strictly speaking that generalizes to any functional context where a generic
 value can be assigned to the else clause, but there don't tend to be that
 many other such contexts.  Does that answer the question?

I believe his question was why if-then-else is syntax, rather than the
function he gave. Since haskell is non-strict, it doesn't need to be
implemented as syntax (unlike, say, scheme, where it needs to be a
special form/macro to avoid executing both branches).

I imagine the answer is that having the syntax for it looks nicer/is
clearer. if a b c could be more cryptic than if a then b else c
for some values of a, b and c.


Also, you get less parenthesis:

myAbs x  = if x  0 then negate x else x

/S
--
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe