hiding imports
Iavor S. Diatchki
diatchki@cse.ogi.edu
Tue, 4 Dec 2001 11:13:39 -0800
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