Changes to Typeable

Gábor Lehel illissius at gmail.com
Sun Sep 23 15:34:28 CEST 2012


On Mon, Feb 13, 2012 at 10:35 AM, Simon Peyton-Jones
<simonpj at microsoft.com> wrote:
> Friends (Ian pointed out that I should have sent this to the libraries list):
>
> The page describes an improved implementation of the Typeable class, making use of polymorphic kinds. Technically it is straightforward, but it represents a non-backward-compatible change to a widely used library, so we need to make a plan for the transition.
>
>         http://hackage.haskell.org/trac/ghc/wiki/GhcKinds/PolyTypeable
>
> Comments?  You can fix typos or add issues directly in the wiki page, or discuss by email
>
> Simon
>

Is the plan right now to put this into GHC 7.8?

I have a few more questions and a modest proposal.

The questions:

- Will it be possible to write e.g. deriving instance Typeable Eq?

- How about deriving instance Typeable Typeable? (It seems Proxy Proxy
works, so maybe this would too.)

- Does it make sense to have an instance for (~)?

- Will instances be provided for the types in base and built-in to GHC?

The modest proposal:

Automatically generate Typeable instances for every type constructor
that is declared. 'deriving Typeable' becomes a no-op.

Is there a use case for *not* having a Typeable instance for a
particular type? I don't see any, but I'll gladly admit to my
misguidedness if there is one. Note that this wouldn't break
parametricity: there wouldn't be any universal instance Typeable a,
rather every individual type would happen to have an instance. The
advantage would be that upstream packages would be spared the tedium
of deriving an instance for every single type, and downstream packages
would be spared the frustration of having to write orphan instances or
submit feature requests and wait for the next release in case upstream
forgets to. Less work for everyone.


-- 
Your ship was destroyed in a monadic eruption.



More information about the Libraries mailing list