Import constructor but not the data type
How do I import a constructor but not its data type? The constructor might have the name of a data type which I do not want to bring into scope.
Use case: Library (A
) defines a parametrized data type (D a
) which I want to use in my code (B
) in instantiated form (D Int
) but with the same name (D
). I want to pattern match against inhabitants of type D
, so I need the constructor(s) in scope.
Here is how it could look like if import lists let me specify whether I want to import a type or a constructor with name "D
".
module A where
data D a = D a
module B where
import A (constructor D)
import qualified A
D = A.D Int
f :: D -> Int
f (D x) = x
Haskell has different name spaces for type and constructors, but does not let the user talk about these name spaces where it matters, namely in import/export lists. At least I found no documentation instructing me how to do this.