[Haskell-cafe] A better syntax for qualified operators?

Brian Hulley brianh at metamilk.com
Fri Sep 29 04:50:11 EDT 2006


Henning Thielemann wrote:
> On Wed, 27 Sep 2006, Brian Hulley wrote:
>>        ith = Data.Array.IArray.(!)
>
> This cool editor is able to show a list of functions with the given
> qualification but is not able to enclose the qualified identifier in
> parentheses?

I hadn't thought of that...

> I don't think that it is a good idea to move the
> qualification away from the qualified identifier. The parentheses
> around the infix operator are a special case of sections. With the
> proposed syntactic change, we would have two meanings of parentheses:
> Section and making an infix operator prefix. One can also mix up
>  Data.Array.IArray.(!)
>    more easily with function composition
>  Data.Array.IArray . (!)
>    if Data.Array.IArray is also a constructor.

Yes this problem was at the back of my mind. I think I'm coming round to the 
view that the original syntax is actually better after all. It also turns 
out that it's rather difficult to deal with Data.Array.IArray.(+) at the 
lexical level because there are 3 different ways in which this can be 
incomplete eg:

    Data.IArray.Array.
    Data.IArray.Array.(
    Data.IArray.Array.(+

leading either to too many different tokens to represent the above 
variations or else a very heavyweight token with many fields.

I had originally thought it would be easier to have (+) and `div` as lexemes 
so that it would be easier to parse expressions involving operators in the 
CFG, but as long as 
http://hackage.haskell.org/trac/haskell-prime/wiki/FixityResolution is 
accepted, this reason will disappear.

Thanks for the good justification of the existing syntax,
Brian.
-- 
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com 



More information about the Haskell-Cafe mailing list