On my proposal for   minBy, gcd ...  :: [a] -> a

and remark on  +, && ...  being the exceptions

Matt Harden <[EMAIL PROTECTED]>  writes on 19 May 2000 

>> (+), (&&) ...  are different. Because they have classical tradition
>> to be applied as binary infix operations.
>> And  gcd, min, max, lcm  have not this "infix" tradition.

> Yes, but the "infix tradition" is not the only reason we have these
> operations.  We have them because they are useful.  They are the
> simplest versions of the operations.  If I want to sum up all the
> elements of a binary tree, for example, I would use (+), not sum,
> because I always want to add two numbers and I don't want the overhead
> of intermediate lists.  The same is true if I want the minimum element
> of the tree.
>

When processing this tree, it would be natural to write in each node
                           m + b  and  min [m,b].

The former is "necessary" due to the infix-binary tradition.
The latter uses [,] because it is good to have one function  min  for a 
list and for the two elements.

> I admit that, if the haskell compiler/interpreter inlines the list
> versions, and implements list deforestation, then the list versions can
> be just as efficient as the curried versions, but we can't always be
> assured of this.

If it does not inline, then it estimates the expence as small. 
You can set an experiment, for example, with Hugs.

The economy of names is more important.

------------------
Sergey Mechveliani
[EMAIL PROTECTED]





Reply via email to