[Haskell-cafe] Fractional/negative fixity?

Carl Witty cwitty at newtonlabs.com
Mon Nov 6 14:15:14 EST 2006


On Fri, 2006-11-03 at 18:07 -0800, Dan Weston wrote:
> Here's an idea that (I think) is useful and backwards compatible: 
> fractional and negative fixity.
> 
> There have been 3 separate times where I've wanted an operator just 
> above 0 ($) but less than 1 (>>= or >>>), or else just below 0 (like a 
> superlow $$)
> 
> infix  0.5 ???
> infix -1   $$
> 
> The only change would be internal to compiler, wouldn't it? Since fixity 
> is just syntactic sugar, there should be no semantic difficulties.

I like it!  One caveat: the grammar from the Haskell Report specifies a
fixed number of precedence levels; if anybody has a Haskell parser
implemented by feeding this grammar into a parser generator, they would
have to rewrite the parser to implement this.  (But it's quite possible
that nobody has such a parser; the alternate approach of using a first
pass that ignores precedences and fixing them up with a second-pass
hand-written operator precedence parser seems to be easier and more
popular, and should be easy to adapt to new precedence levels.)

Carl Witty




More information about the Haskell-Cafe mailing list