I think it's an ill-thought-out exception. The point is this: if a data constructor cannot appear on its own in a hiding list, then you can't hide the constructor without hiding the type. Currently you can say import Maybe hiding( Just ) It would be simpler and more uniform to only allow data constructors inside parens, just as for exports, but then I'd have to say import Maybe hiding( Maybe(Just) ) and now the type constructor Maybe is hidden too. I say "ill thought out" because the exception doesn't actually solve the problem, as you point out. You may accidentally hide things you didn't mean to. So perhaps the cure is as bad as the disease. Changing this would be technically easy (delete a sentence) but it might break some programs, so that suggests the status quo. Simon | -----Original Message----- | From: Iavor S. Diatchki [mailto:diatchki@cse.ogi.edu] | Sent: 04 December 2001 19:14 | To: haskell@haskell.org | Subject: hiding imports | | | hello, | | i was wondering if there was a reasong why "hiding imports" | have different semantics from "importing imports" and | "exports". what i mean is, if one | writes: | | module A(T) where | data T = T | only the type constructor T is exported. simillarly if i write: | | module A where | data T = T | | module B where | import A(T) | | only the type constructor is imported, but if i write | (module A as above) | | module B where | import A hiding (T) | | both the type constructor and the value constructor are hidden. | | this seems not only irregular, but may also be inconvinient | in practise as sometimes it happens that a type constructor | and a data constructor have the same name, but the data | constructor does not "belong" to the type constructor. for example: | | module A where | type T = TGen Int | data TGen a = T a | S | | module B where | import A hiding (T) -- intending to just hide the type T | genF = T -- error T not in scope! | | so if i wanted to ignore the type T, but still have the data | constructor i | have to explicitly import it, i.e. write: | module B where | import A hiding (T) | import A (TGen(T)) | which is kind of ugly. is this strange behaviour for | historical reasons, | or was there a practical reason why this decision was made? | | bye | iavor | | | _______________________________________________ | Haskell mailing list | Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell |