Corentin Dupont | 28 Feb 18:28 2014
Picon

export DataKinds

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
Richard Eisenberg | 28 Feb 19:36 2014

Re: export DataKinds

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
Corentin Dupont | 28 Feb 19:45 2014
Picon

Re: export DataKinds

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


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane