Can we simplify Dynamic?
Simon Peyton Jones
simonpj at microsoft.com
Fri Oct 2 19:42:07 UTC 2015
It seems to be a fairly popular proposal. =)
Indeed. Ben Price (now at Strathclyde) did a short internship at MSR working on this; see
https://ghc.haskell.org/trac/ghc/wiki/TypeableT
Dimitrios, Stephanie, Richard, and I are working on a paper about it, which should be out in a couple of weeks.
At that point we’ll be in a position to have a proper core-libraries-committee discussion about the right API etc; I hope we can make the result part of GHC 8.0.
But I want to get the paper out first since it gives a reasonably articulate exposition of the ideas and rationale, so that we all start on the same page.
Simon
From: Libraries [mailto:libraries-bounces at haskell.org] On Behalf Of Edward Kmett
Sent: 29 September 2015 16:53
To: Roman Cheplyaka
Cc: Haskell Libraries
Subject: Re: Can we simplify Dynamic?
It seems to be a fairly popular proposal. =)
https://mail.haskell.org/pipermail/libraries/2014-August/023633.html<https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fmail.haskell.org%2fpipermail%2flibraries%2f2014-August%2f023633.html&data=01%7c01%7csimonpj%40064d.mgd.microsoft.com%7c4a20632c14424882676b08d2c8e5fe0e%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=Q8v9rdZ4Q%2bnw7oER7kBQb42HIXiujZOEmkO%2fQPOqe0g%3d>
-Edward
On Mon, Sep 28, 2015 at 6:03 PM, Roman Cheplyaka <roma at ro-che.info<mailto:roma at ro-che.info>> wrote:
I suggested this last year, see this thread
https://mail.haskell.org/pipermail/libraries/2014-March/022287.html<https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fmail.haskell.org%2fpipermail%2flibraries%2f2014-March%2f022287.html&data=01%7c01%7csimonpj%40064d.mgd.microsoft.com%7c4a20632c14424882676b08d2c8e5fe0e%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=NllZIb67%2fxgH1fNXfMJ5nsgWm%2bwRpfXEBWt4kPlS9AM%3d>
On 09/29/2015 12:51 AM, David Feuer wrote:
> Currently,
>
> data Dynamic = Dynamic TypeRep Obj
> deriving Typeable
> where
> type Obj = Any
>
> As a result, all of the operations must be implemented "by hand" using
> unsafeCoerce. The more obvious representation these days would seem to be
>
> data Dynamic where
> Dynamic :: Typeable a => a -> Dynamic
>
> Most of the operations then become trivial applications of Typeable
> functions. The only exceptions seem to be dynApply and dynApp. That
> there are exceptions strikes me as quite unfortunate. The easiest fix is
> inspired by the fact that Data.Dynamic uses
>
> funResultTy :: TypeRep -> TypeRep -> Maybe TypeRep
>
> from Data.Typeable to decide whether to coerce. It seems reasonable to
> add a more informative version, something like
>
> applyTypeable :: (Typeable f, Typeable a) =>
> proxy f ->
> proxy a ->
> (forall b . (Typeable b, f ~ (a -> b)) => r) ->
> Maybe r
>
> On the other hand, it would be really cool if there were some more
> general way to get type-level information out of Typeable instances,
> pattern matching on the type constructors.
_______________________________________________
Libraries mailing list
Libraries at haskell.org<mailto:Libraries at haskell.org>
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries<https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.haskell.org%2fcgi-bin%2fmailman%2flistinfo%2flibraries&data=01%7c01%7csimonpj%40064d.mgd.microsoft.com%7c4a20632c14424882676b08d2c8e5fe0e%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=Yb6xCqACYgr8gw%2ffKgyGvWooH2vs1S6kriYtUAV8LQg%3d>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20151002/40d297ce/attachment-0001.html>
More information about the Libraries
mailing list