Import constructor but not the data type
|Reported by:||andreas.abel||Owned by:|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Revisions:|
Description (last modified by hvr)
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.
Change History (11)
comment:6 Changed 10 months ago by nomeata
- Resolution set to fixed
- Status changed from new to closed
comment:8 Changed 10 months ago by nomeata
- Component changed from Compiler to Documentation
- Resolution fixed deleted
- Status changed from closed to new
- Type changed from feature request to task