prefix minus and infix resolution

Christian Maeder Christian.Maeder at dfki.de
Wed Jul 14 06:01:45 EDT 2010


Malcolm Wallace schrieb:
>> I'm asking for support of:
>> http://hackage.haskell.org/trac/haskell-prime/wiki/PrefixMinusResolution
> 
> Just to note that nhc98 appears to fulfill the outcome of this
> resolution algorithm already, with the exception of example x7, which is
> parsed as -(4#5).

Because it seems to (unnecessarily) check if the operator # is
left-associative. I assume that for "infixr 6 #" the term "-4 # 5 # 6"
is resolved as "-(4 # (5 # 6))" (like it would be for "^").

How can I try out nhc98? My old installation is broken and
http://www.haskell.org/haskellwiki/Implementations#nhc98
refers to no implementation. Is Yhc the compiler I should try?

> 
> However, nhc98 goes further and permits the declaration of arbitrary
> prefix operators, using the syntax
> 
>     prefix negate 6 -

yes, this is a nice extension.

> yes, in addition to
> 
>     infix 6 -
> 
> I think the rationale is that the prefix symbol must map to a
> non-symbolic function name, because the same symbol may also refer to a
> function of a different type when used infix. 

Currently there is no haskell way to _define_ a prefix operator
therefore prefix minus is bound to negate explicitly as above (nhc98) or
implicitly built-in (ghc and hugs).

Prefix- and Infix-usage can be distinguished by the lexer:

  - a ... -> prefix

  a - ... -> infix

Furthermore, prefix minus can not be qualified (bug or feature?).

Prelude.- only refers to the infix version and "Prelude.- 1" is rejected
(by ghc and hugs).

Cheers Christian



More information about the Haskell-prime mailing list