
Hi Cafe, I create kinds using the DataKinds extension: {-# LANGUAGE DataKinds #-} module MyModule where data Foo = Bar | Baz The problem is that the generated Bar and Baz type constructors are not exported! I am obliged to put the pragma DataKinds in every package that uses MyModule (a lot). Is there a way to avoid that? Thanks! Corentin

Promoted data constructors aren't imported/exported separately from the normal data constructors. So, to use a promoted data constructor in an importing module, you need to import the normal data constructor and then promote it, with DataKinds. But, here is a workaround:
{-# LANGUAGE DataKinds #-} data Foo = Bar | Baz type Bar = 'Bar type Baz = 'Baz
This defines (normal, not promoted) type synonyms for the promoted data constructors. Because the namespace for types and the one for data constructors are distinct, you can even reuse the same names. In a quick test, an importing module was able to use these without DataKinds specified. I hope this helps! Richard On Feb 28, 2014, at 12:28 PM, Corentin Dupont wrote:
Hi Cafe, I create kinds using the DataKinds extension:
{-# LANGUAGE DataKinds #-}
module MyModule where
data Foo = Bar | Baz
The problem is that the generated Bar and Baz type constructors are not exported! I am obliged to put the pragma DataKinds in every package that uses MyModule (a lot). Is there a way to avoid that?
Thanks! Corentin
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Thanks!
On Fri, Feb 28, 2014 at 7:36 PM, Richard Eisenberg
Promoted data constructors aren't imported/exported separately from the normal data constructors. So, to use a promoted data constructor in an importing module, you need to import the normal data constructor and then promote it, with DataKinds.
But, here is a workaround:
{-# LANGUAGE DataKinds #-} data Foo = Bar | Baz type Bar = 'Bar type Baz = 'Baz
This defines (normal, not promoted) type synonyms for the promoted data constructors. Because the namespace for types and the one for data constructors are distinct, you can even reuse the same names. In a quick test, an importing module was able to use these without DataKinds specified.
I hope this helps! Richard
On Feb 28, 2014, at 12:28 PM, Corentin Dupont wrote:
Hi Cafe, I create kinds using the DataKinds extension:
{-# LANGUAGE DataKinds #-}
module MyModule where
data Foo = Bar | Baz
The problem is that the generated Bar and Baz type constructors are not exported! I am obliged to put the pragma DataKinds in every package that uses MyModule (a lot). Is there a way to avoid that?
Thanks! Corentin
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (2)
-
Corentin Dupont
-
Richard Eisenberg