[Haskell-beginners] Re: map question
Will Ness
will_n48 at yahoo.com
Sun Oct 18 07:11:07 EDT 2009
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 (:[]).
Except for `-`, where it would finally provide us with possibility to write a
shortcut for the ugly (flip (-) 1) as (`-`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.
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.
More information about the Beginners
mailing list