<div dir="ltr">Ok, but what I am curious about if the tag in the info table could be globally unique?<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 12, 2020 at 9:01 PM Vladislav Zavialov <<a href="mailto:vladislav@serokell.io">vladislav@serokell.io</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The globally unique tag for data constructors already exists, it’s a pointer to the StgInfoTable. You can observe it using getClosureRaw from GHC.HeapView<br>
<br>
Example:<br>
<br>
Prelude GHC.HeapView> getClosureRaw Nothing<br>
(0x0000000107fd8e38,[4429024840,4429024752],[])<br>
<br>
Here, the globally unique tag is 0x0000000107fd8e38.<br>
<br>
Note that newtype constructors do not get their own tag because newtypes guarantee that they do not change the underlying representation of data.<br>
<br>
I’ve discovered the existence of such a tag only recently (Alexander Vershilov pointed it out to me), so I cannot say if it’s a reliable way to identify data constructors. For example, it is definitely not stable across several runs of the same binary. However, within a single run, it seems to work.<br>
<br>
- Vlad<br>
<br>
> On 12 Feb 2020, at 21:57, Csaba Hruska <<a href="mailto:csaba.hruska@gmail.com" target="_blank">csaba.hruska@gmail.com</a>> wrote:<br>
> <br>
> Hello,<br>
> <br>
> In theory could GHC codegen work if every data constructor in the whole program  have a globally unique tag value instead of starting from 1 for each algebraic data type?<br>
> Would this break any GHC design decision?<br>
> <br>
> Regards,<br>
> Csaba<br>
> _______________________________________________<br>
> ghc-devs mailing list<br>
> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
<br>
</blockquote></div>