[Haskell-cafe] Class-like features for explicit arguments

Ertugrul Söylemez ertesx at gmx.de
Sat Apr 25 21:58:18 UTC 2015


> are you sure you've evaluated how it interacts with this sort of
> optimization? I think it actually gets you pretty far!

Most of the magic occurs in reification.  The trouble is that it expects
a polymorphic function of rank 2 with a nontrivial context (Reifies), a
function that by construction cannot be specialised, unless you
specialise the receiving function (reify) for every application case.
The beauty of reflection is that it's free by virtue of sharing.
Unfortunately sharing is the exact opposite of inlining.

According to a benchmark I've done a few months ago it behaves exactly
as if the reflected value was just a shared argument with no inlining
performed; an expected and reasonable result.

What I'm really after is a sort of controlled inlining.  That's pretty
much what instance-based specialisation currently does for dictionaries.
Technically a dictionary is just another argument, so there is no
fundamental reason why we shouldn't have a more general specialiser.


>> > Here yah go https://hackage.haskell.org/package/reflection
>> > It exploits how dictionary passing works in a pretty robust way that
>> > ghc is likely to at some point codify officially.
>>
>> Oh, that one.  Of course I'm familiar with it, but it's less an
>> optimisation than a clever way to implement implicit configurations.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150425/3958aaa5/attachment.sig>


More information about the Haskell-Cafe mailing list