[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-cafe
Subject:    Re: [Haskell-cafe] export DataKinds
From:       Corentin Dupont <corentin.dupont () gmail ! com>
Date:       2014-02-28 18:45:47
Message-ID: CAEyhvmpx8F1VN6q_1ZM+naZqcq5AuJ2suXRfo3ca=KvT6dn_Aw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Thanks!


On Fri, Feb 28, 2014 at 7:36 PM, Richard Eisenberg <eir@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@haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>

[Attachment #5 (text/html)]

<div dir="ltr">Thanks!<br></div><div class="gmail_extra"><br><br><div \
class="gmail_quote">On Fri, Feb 28, 2014 at 7:36 PM, Richard Eisenberg <span \
dir="ltr">&lt;<a href="mailto:eir@cis.upenn.edu" \
target="_blank">eir@cis.upenn.edu</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Promoted data constructors aren&#39;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.<br>

<br>
But, here is a workaround:<br>
<br>
&gt; {-# LANGUAGE DataKinds #-}<br>
<div class="">&gt; data Foo = Bar | Baz<br>
</div>&gt; type Bar = &#39;Bar<br>
&gt; type Baz = &#39;Baz<br>
<br>
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.<br>

<br>
I hope this helps!<br>
Richard<br>
<div><div class="h5"><br>
On Feb 28, 2014, at 12:28 PM, Corentin Dupont wrote:<br>
<br>
&gt; Hi Cafe,<br>
&gt; I create kinds using the DataKinds extension:<br>
&gt;<br>
&gt; {-# LANGUAGE DataKinds #-}<br>
&gt;<br>
&gt; module MyModule where<br>
&gt;<br>
&gt; data Foo = Bar | Baz<br>
&gt;<br>
&gt; The problem is that the generated Bar and Baz type constructors are not \
exported!<br> &gt; I am obliged to put the pragma DataKinds in every package that \
uses MyModule (a lot).<br> &gt; Is there a way to avoid that?<br>
&gt;<br>
&gt; Thanks!<br>
&gt; Corentin<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Haskell-Cafe mailing list<br>
&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" \
target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br> <br>
</blockquote></div><br></div>



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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic