# Fractional/negative fixity?

Jan-Willem Maessen jmaessen at alum.mit.edu
Wed Nov 8 21:02:13 EST 2006

```On Nov 7, 2006, at 5:49 PM, Robert Dockins wrote:
[On operator precedence]
>
>
> Ha! Well, as long as we're being pedantic, surely we wouldn't need
> any set
> larger than the rationals (which does have a decidable ordering)?
>
> Also, since I'm commenting anyway, I rather like the idea of
> specifying
> operator precedences via a partial order.  However, I also feel
> that there
> needs to be some work done to make sure there aren't gremlins
> hiding in the
> details.  Has anyone worked out the theory on this?  How does
> associating to
> the right vs left play into the picture?  How does it fit into the
> parsing
> technology?

Actually, we *do* use a DAG on operator precedence in the Fortress
programming language (my day job).  Our goal is to require
parentheses when it is not blatantly obvious what is going on (eg
because we're using operators from two libraries written in
isolation).  We can only use operators together in an expression
without parentheses if there is an edge between them in the graph.
Graph nodes are sets of operators with the "same" precedence (eg
addition and subtraction).  Among other things this means that if ++
has higher precedence than ==, and == has higher precedence than &&,
we can't necessarily mix ++ and && in the same expression without
parentheses.

That said, this would be a pretty big change for Haskell, and would
break existing code unless you somehow wired in the transitive
closure of all the existing operators.  As another message in this
discussion (from Simon M?) mentioned, you might want to be able to
specify the relationship between operators imported from different
modules, because you *do* know that a well-known relationship exists.

-Jan-Willem Maessen

>
>
>
> --
> Rob Dockins
>
> Talk softly and drive a Sherman tank.
> Laugh hard, it's a long way to the bank.
>        -- TMBG
> _______________________________________________

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2425 bytes
Desc: not available
```