Fixity declarations

Simon Peyton-Jones
Thu, 12 Jul 2001 09:21:33 -0700

Current wording is "A fixity declaration may appear anywhere that a type
signature appears and, like a type signature, declares a property of a
particular operator. Also like a type signature, a fixity declaration
can only occur in the same declaration group as the declaration of the
operator itself, and at most one fixity declaration may be given for any

Indeed, you can't give either a type signature or a fixity declaration
for a pattern-bound variable.  (By pattern-bound I include case
expressions, function left hand sides etc.)

Would it really help to say that you can't give a fixity for
a pattern-bound variable?  (After all, there are many other things you
can't do.)
If so, should we not say the same about type signatures?
Are there other things that  you can't do that should be identified?


| -----Original Message-----
| From: Koen Claessen []=20
| Sent: 12 July 2001 17:00
| To: The Haskell Mailing List
| Subject: Fixity declarations
| 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 =3D x # y # z
|     where
|       infixr 4 #
|       a # b =3D 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) =3D 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=20
| 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=20
| the report should be clear about that it is not possible to=20
| define the fixities of locally bound operator names in this way.
| /Koen.
| _______________________________________________
| Haskell mailing list