Another question wrt hiding imports
After the recent discussion import hiding clauses in import declarations, I was wondering what the meaning of hiding clauses is in the case of algebraic data types (or classes). For instance if a have module A where data T = A | B which entities are imported when I include the declaration import A hiding(T) in a module? The report is not clear about this but I would expect that this imports data constructors A and B into the current module but not the type constructor T -- otherwise, what would be the meaning of import A hiding(T(B))? However, if this is true it is possible to export data constructors without their type via module B(module A) where import A hiding(T) which contradicts the statement in section 5.2 on p.64, that the form module m is equivalent to listing all entities imported from that module, because I cannot list a data constructor (without its type) in an export specification. Wolfgang -- Wolfgang Lux Phone: +49-251-83-38263 Institut fuer Wirtschaftinformatik FAX: +49-251-83-38259 Universitaet Muenster Email: wlux@uni-muenster.de
I asked this a while ago and never got an answer. Asking again in better context: How do you control importing operator precedence? Suppose that you have: f x = 2 + 2 * x And an imported module increases the precedence of (+). You end up getting mangled. My assumption is that the only way to protect yourself from this is to import qualified so A.+ has a different precedence from +. But I don't think the report promises this. The report just promises that A.+ has the same precedence as (+) inside module A. -Alex- ___________________________________________________________________ S. Alexander Jacobson Shop.Com 1-646-638-2300 voice The Easiest Way To Shop (sm)
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.
Koen Claessen wrote
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.
Hmmm, unless I overlooked something your example is syntacally not valid by the grammar given in appendix B.4 of the Haskell 98 report. Operators in patterns can be used only with an infix syntax. Wolfgang -- Wolfgang Lux Phone: +49-251-83-38263 Institut fuer Wirtschaftinformatik FAX: +49-251-83-38259 Universitaet Muenster Email: wlux@uni-muenster.de
participants (3)
-
Koen Claessen -
S. Alexander Jacobson -
Wolfgang Lux