Fixity declarations

Simon Peyton-Jones simonpj@microsoft.com
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
operator."

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?

Simon

| -----Original Message-----
| From: Koen Claessen [mailto:koen@cs.chalmers.se]=20
| Sent: 12 July 2001 17:00
| To: The Haskell Mailing List
| Subject: Fixity declarations
|=20
|=20
| Hi all,
|=20
| The topic is fixity declarations for operators.
|=20
| The report says:
|=20
|   "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."
|=20
| It is possible to define fixities for locally declared
| bindings:
|=20
|   f x y z =3D x # y # z
|     where
|       infixr 4 #
|       a # b =3D a `div` b
|=20
| The use of (#) in the body of g is right associative.
|=20
| However, it is not possible to define the fixity of an
| operator which is an argument to a function. If I define:
|=20
|   foldr4 :: (a -> b -> b) -> b -> (a,a,a,a) -> b
|   foldr4 (#) z (a,b,c,d) =3D a # b # c # d # z
|=20
| 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).
|=20
| In this case, (#) gets the default fixity, namely infixl 9.
|=20
| 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.
|=20
| /Koen.
|=20
|=20
| _______________________________________________
| Haskell mailing list
| Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
|=20