Fixity declarations

Koen Claessen koen@cs.chalmers.se
Thu, 12 Jul 2001 17:59:31 +0200 (MET DST)


Hi all,

The topic is fixity declarations for operators.

The report says:

  "Fixity is a property of a particular entity (constructor
   or variable), just like its type; fixity is not a
   property of that entity's name."

It is possible to define fixities for locally declared
bindings:

  f x y z = x # y # z
    where
      infixr 4 #
      a # b = a `div` b

The use of (#) in the body of g is right associative.

However, it is not possible to define the fixity of an
operator which is an argument to a function. If I define:

  foldr4 :: (a -> b -> b) -> b -> (a,a,a,a) -> b
  foldr4 (#) z (a,b,c,d) = a # b # c # d # z

I will have to put in parentheses explicitly, because it is
not possible to define the fixity of that entity (namely the
argument (#) to foldr4).

In this case, (#) gets the default fixity, namely infixl 9.

Apart from the fact if we want to allow this or not, I think
the report should be clear about that it is not possible to
define the fixities of locally bound operator names in this
way.

/Koen.