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

Brian Hulley brianh at metamilk.com
Thu Sep 28 02:10:39 EDT 2006

Brandon Moore wrote:
> Brian Hulley wrote:
>> I would *like* to be able to use the syntax:
>>        ith = Data.Array.IArray.(!)
> Why does the nice argument not apply equally well to infixifying
> things? Shouldn't I be able to write
> myArr Data.Arr.`get` ix

Good point. This would also remove the need for allowing double conversion 
as in OpIdOp which was an element of asymmetry in my original proposal. Thus 
I revise my proposal to the following:

    varId ::= id
    varOp ::= symbol
    varIdOp ::= ` varId `
    varOpId ::= ( varOp )

    q<x> ::= {conId .}+ x

so the concerns of qualification and Id, Op, Id<->Op would now be separated 
(the point being that you can only make a decision regarding Id<->Op when 
you know whether or not you're starting with an Id or an Op and you only 
know this latter fact when you've already "arrived" at the module by typing 
the qualifier).

>> (Also the trailing backquote in the existing syntax is redundant)
> The trailing backquote is just as redundant as the trailing close
> paren in the syntax for using a symbol as a prefix function and just
> as important for my comment on backticks as the closing paren is to
> your proposal for sections -
> it means it's lexically apparent at least at one side of the
> identifier that it's a section/infixification

I'm not sure I understand this argument for why a trailing backquote is 
needed, though I can see it would be needed if the dist-fix idea proposed by 
Benjamin Franksen in 
http://www.haskell.org/pipermail/haskell-cafe/2006-August/017373.html was 
adopted eg:

    Control.K.`if cond Control.K.`then` t Control.K.`else` f Control.K.fi`

Regards, 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.


More information about the Haskell-Cafe mailing list