Changes to Typeable

Gábor Lehel illissius at gmail.com
Sun Oct 14 14:34:37 CEST 2012


So apologies for constantly suggesting new things, but if we have,

- All Typeable instances for type constructors are generated by the
compiler, and
- All Typeable instances for composite types (if that's the word?) are
via instance (Typeable f, Typeable a) => Typeable (f a), and
- User-written instances, and therefore overlap, are disallowed,

how difficult would it be to add:

foo :: Typeable (f a) => Dict (Typeable f, Typeable a)
-- data Dict c where Dict :: c => Dict c

i.e. to make it possible to go in the other direction, and deduce that
if a composite type is Typeable, its components must also be?

(alternate encoding: foo :: Typeable (f a) => ((Typeable f, Typeable
a) => r) -> r)

Use case: nothing very serious, if it would take significant work,
it's not worth it.

On Fri, Oct 5, 2012 at 9:06 AM, Simon Peyton-Jones
<simonpj at microsoft.com> wrote:
> | Does this imply forbidding user-written instances of Typeable? If yes,
> | then I guess some currently accepted programs would also be rejected
> | (those with manual instances)?
>
> Yes, that's the idea; I should have said that.  Allowing users to write instances leads to potential un-soundness when doing dynamic type casts, so it has always been a Bad Idea.
>
> Simon
>
>



-- 
Your ship was destroyed in a monadic eruption.



More information about the Libraries mailing list