Am Sonntag 18 Oktober 2009 13:11:07 schrieb Will Ness:
> Brent Yorgey <byorgey <at> seas.upenn.edu> writes:
> > On Sat, Oct 17, 2009 at 06:29:39PM +0000, Will Ness wrote:
> > > Then why wouldn't (`-`1) parse at at all? And not even (`(-)`1) ?
> > >
> > > I know this doesn't parse, my question is, why wouldn't it be made
> > > valid syntax? It seems consistent. (`mod`2) parses, why not (`-`2) ?
> >
> > `backticks` are only for making (prefix) functions into (infix)
> > operators. - is already an infix operator, so putting it in backticks
> > would be redundant. As for `(-)`, arbitrary expressions cannot go
> > inside backticks, and for good reason: what would `(2 `mod`)` parse
> > as?
> >
> > However, certainly different choices might have been possible.
> >
> > -Brent
>> backticks could've been made no-op for operators. What's so wrong with
> (`:`[])? It'd just be the same as (:[]).
Makes writing the parser more complicated.
Makes reading code more irritating.
>> Except for `-`, where it would finally provide us with possibility to write
> a shortcut for the ugly (flip (-) 1) as (`-`1).
That's ugly too.
My favourite is subtract 1.
>> (2`mod`) is a unary operation :: (Integral a) => a -> a. Putting it inside
> backticks would require it be a binary infix op, causing a type mis-match.
instance (Integral a) => Integral (b -> a) where ...
Evil, yes, but then f `(2 `mod`)` x would type-check.
But anyway, there are operators where a backticked section would type-check:
f `(g `.`)` x
That's not good.
>> For (-) it could choose the binary version over the unary.
>> Or it could stay illegal for the parenthesised expressions, and just made
> legal syntax for operators, as (`:`[]).
>> I don't know how easy or even possible it is to implement; I'm just saying
> it makes sense, for me.
But it has downsides.