"S.D.Mechveliani" wrote:

> (+), (&&) ...  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.

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.

For economy of function names, and to avoid confusion between the
curried and list versions of operations, I would suggest an "L" suffix
for the list versions (not including sum, concat, etc.):

   min    :: (Ord a) => a -> a -> a
   minL   :: (Ord a) => [a] -> a
   minBy  :: (a -> a -> Ordering) -> a -> a -> a
   minLBy :: (a -> a -> Ordering) -> [a] -> a

   gcd    :: (Integral a) -> a -> a -> a
   gcdL   :: {Integral a) -> [a] -> a

Best regards,
Matt Harden <[EMAIL PROTECTED]>

Reply via email to