Optimizing "counting" GADTs

Ben Gamari ben at smart-cactus.org
Sun Jun 19 08:27:55 UTC 2016


"Edward Z. Yang" <ezyang at mit.edu> writes:

snip

>> Dictionaries are harder to come by,
>> but reflection might be an option.
>
> If I understand correctly, even if you have a Typeable dictionary you
> don't necessarily have a way of constructing the other dictionaries
> that are available at that type.  Maybe that is something worth fixing.
>
Right; a Typeable dictionary gives you nothing more than the identity of
the type. You cannot get any further dictionaries from it. Honestly
fixing this seems quite non-trivial (essentially requiring that you
construct a symbol name for the desired dictionary and do a symbol table
lookup to find it, hoping that the linker didn't decide to drop it due
to being unused).

Moreover, it seems possible that providing this ability may have
consequences on parametricity. Reflection already comes dangerously
close to compromising this property; we are saved only by the fact that
a Typeable constraint is needed to request a representation. I'd imagine
that allowing the user to produce arbitrary dictionaries from a
representation may pose similar issues.

Cheers,

- Ben
-------------- 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/ghc-devs/attachments/20160619/bc01a5e2/attachment.sig>


More information about the ghc-devs mailing list