Import constructor but not the data type
|Reported by:||andreas.abel||Owned by:|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Rev(s):|
Description (last modified by )
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 "
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.
Change History (11)
comment:8 Changed 3 years ago by
|Component:||Compiler → Documentation|
|Status:||closed → new|
|Type:||feature request → task|