RE: Fixity declarations
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] | 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 = 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. | | | _______________________________________________ | Haskell mailing list | Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell |
participants (1)
-
Simon Peyton-Jones