[Haskell-beginners] Re: map question
daniel.is.fischer at web.de
Sun Oct 18 20:27:42 EDT 2009
Am Sonntag 18 Oktober 2009 22:40:46 schrieb Will Ness:
> Daniel Fischer <daniel.is.fischer <at> web.de> writes:
> > Am Sonntag 18 Oktober 2009 13:11:07 schrieb Will Ness:
> > > 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.
> I suspected as much, but if it has some benefits, that would be justified.
I think you mean "if the benefits outweigh the downsides".
If they do (or rather, if enough people believe they do and few enough believe it's the
other way round), then it's justified.
As of now, I don't believe it has substantial benefits (consequences which I regard as
> > > 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.
> We could write (hypothetically) 'concatenate' for ++ too, but we don't.
> What's so great with writing out long names, that should be processed,
> mentally, to get at their meaning, when we have this nice operators syntax
> which makes the meaning immediately - visibly - apparent?
Operator syntax per se doesn't make the meaning immediately apparent.
Only the meaning of well known operators (like +,-,*,/) and, to some extent, close
derivations of them (like ++) is readily apparent. ($) or (>>=) aren't obvious when you
first see them.
However, I didn't want to advocate the use of alphabetic identifiers instead of operators,
I meant that since (- 1) doesn't work, my favourite way to express it is (subtract 1).
I find that nicer than (flip (-) 1), and also aesthetically superior to (`-` 1).
Purely personal taste, of course.
> The only problem in Haskell syntax is this unary-over-binary (-), so
Yes, that's unpleasant. However, for me it's a minor point.
> allowing backticks for operators as well as for regular names would finally
> provide a solution for it.
> Nobody would use it except for (-) sections.
Are you sure?
People abuse every oportunity you give them and then some, so I wouldn't be
too surprised if gratuitous backticks seeped into Haskell code over time.
> Or even, hypothetically, it
> could be used to allow unary operators in the language, in general. That
> whould be a mechanism for distinguishing the binary from the unary
> Why not? Difficulty of writing a parser is not a valid reason if there's a
> clear utility in it. IMHO.
More information about the Beginners