<p dir="ltr">I forgot to thank you and the rest for your tremendous work on this! I know you said the page is a bit out of date, but I had an idea about fingerprints you may want to consider if you haven't already. In particular, the wiki page indicates that TTypeRep would have to be abstract to prevent fingerprint forgeries, but I don't think that's necessarily correct. I would think you could instead index the Fingerprint# type with the type it identifies. You'd probably want to add a new magical Fingerprinted class to produce fingerprints, and a magic function to use them. The fingerprints could actually be used completely independently to improve performance in contexts where the full power of TTypeRep isn't required. Then the TTyperep nodes could hold Fingerprint#s, but themselves be concrete. Presumably, Fingerprinted => Typeable. Maybe this idea is crazy, but I figured I'd put it out there.</p>
<p dir="ltr">BTW, I'm a bit astonished that I managed to come up with pretty much exactly the same function application mechanism that you gave as the most basic sort of interface.</p>
<div class="gmail_quote">On Sep 28, 2015 6:11 PM, "Richard Eisenberg" <<a href="mailto:eir@cis.upenn.edu">eir@cis.upenn.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">And indeed it's  a good idea! And indeed it's happening!<br>
<br>
See, for example, <a href="https://ghc.haskell.org/trac/ghc/wiki/Typeable" rel="noreferrer" target="_blank">https://ghc.haskell.org/trac/ghc/wiki/Typeable</a><br>
But that's now a bit out of date.<br>
<br>
Simon PJ, Dimitrios Vytiniotis, Stephanie Weirich and I are hard at work writing a paper about all of this, and we expect the results to be in GHC 8.0, with this Dynamic:<br>
<br>
data Dynamic where<br>
  Dynamic :: TypeRep a -> a -> Dynamic<br>
<br>
Note that TypeRep is now indexed. This is a breaking change, and I'll admit we haven't worked out the migration path. But we're focused on figuring out, precisely, where we're going before worrying too hard about how, precisely, we shall get there.<br>
<br>
But, a much better question from my standpoint is:<br>
Why do you care? Why do you use Dynamic? We're actually struggling a bit in the motivation section of the paper and would love to know why you care. :)<br>
<br>
Thanks!<br>
Richard<br>
<br>
On Sep 28, 2015, at 6:03 PM, Roman Cheplyaka <<a href="mailto:roma@ro-che.info">roma@ro-che.info</a>> wrote:<br>
<br>
> I suggested this last year, see this thread<br>
> <a href="https://mail.haskell.org/pipermail/libraries/2014-March/022287.html" rel="noreferrer" target="_blank">https://mail.haskell.org/pipermail/libraries/2014-March/022287.html</a><br>
><br>
> On 09/29/2015 12:51 AM, David Feuer wrote:<br>
>> Currently,<br>
>><br>
>> data Dynamic = Dynamic TypeRep Obj<br>
>>               deriving Typeable<br>
>> where<br>
>> type Obj = Any<br>
>><br>
>> As a result, all of the operations must be implemented "by hand" using<br>
>> unsafeCoerce. The more obvious representation these days would seem to be<br>
>><br>
>> data Dynamic where<br>
>>  Dynamic :: Typeable a => a -> Dynamic<br>
>><br>
>> Most of the operations then become trivial applications of Typeable<br>
>> functions.    The only exceptions seem to be  dynApply and dynApp. That<br>
>> there are exceptions strikes me as quite unfortunate. The easiest fix is<br>
>> inspired by the fact that Data.Dynamic uses<br>
>><br>
>> funResultTy :: TypeRep -> TypeRep -> Maybe TypeRep<br>
>><br>
>> from Data.Typeable to decide whether to coerce. It seems reasonable to<br>
>> add a more informative version, something like<br>
>><br>
>> applyTypeable :: (Typeable f, Typeable a) =><br>
>>   proxy f -><br>
>>   proxy a -><br>
>>   (forall b . (Typeable b, f ~ (a -> b)) => r) -><br>
>>   Maybe r<br>
>><br>
>> On the other hand, it would be really cool if there were some more<br>
>> general way to get type-level information out of Typeable instances,<br>
>> pattern matching on the type constructors.<br>
><br>
><br>
> _______________________________________________<br>
> Libraries mailing list<br>
> <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>