[Haskell-cafe] export DataKinds

Corentin Dupont corentin.dupont at gmail.com
Fri Feb 28 18:45:47 UTC 2014


Thanks!


On Fri, Feb 28, 2014 at 7:36 PM, Richard Eisenberg <eir at cis.upenn.edu>wrote:

> 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 at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140228/4c050990/attachment.html>


More information about the Haskell-Cafe mailing list