Unary operators [was: Re: ~ patterns]

Benjamin Franksen benjamin.franksen at bessy.de
Thu Feb 2 18:29:47 EST 2006


On Thursday 02 February 2006 23:25, Wolfgang Jeltsch wrote:
> Am Mittwoch, 1. Februar 2006 01:32 schrieb Patryk Zadarnowski:
> > [...]
> >
> > The proposal would be to remove the unary "-" altogether, and,
> > instead, extend the lexical syntax of numeric constant to allow "+"
> > and "-" prefix.
>
> Would this mean that (-x) is a section while (-1) isn't?  That would
> be confusing.
>
> Apart from this, I would like to see the only unary operator of
> Haskell removed.

I'd rather have operator sections removed. They are not very intuitive 
anyway and can be easily replaced, i.e.

(+ x) ---> flip (+) x
(x +) ---> (+) x

which could profit from the proposal to generalize currying:

f ? === (\x -> f x)

[I prefer '?' for the 'left out' argument, rather than '_']

We could then replace the section

(+ x) ---> (+) ? x

or even

(+ x) ---> (? + x)

This would open the possibility to allow unary (prefix) operators in 
general which I find rather more useful than sections.

Ben


More information about the Haskell-prime mailing list