Proxy and new-typeable

Roman Cheplyaka roma at
Fri Apr 19 08:55:32 CEST 2013

* Shachaf Ben-Kiki <shachaf at> [2013-04-18 23:43:41-0700]
> On Thu, Apr 18, 2013 at 11:56 AM, Richard Eisenberg <eir at> wrote:
> > Hi Ben,
> >
> > Oops. I had updated this page [] with details but forgot to advertise. Pedro and I are scheduled to discuss next week, and I do hope that this get implemented/committed before April is out.
> >
> > Richard
> >
> There's another possible approach to the Proxy mess: Instead of using
> or mentioning Proxy anywhere in the Typeable API, make Maybe the
> "official" way to use typeRep.
> The argument is something like: You want to get a TypeRep of a type,
> but you may or may not have a value of that type. If you do, you pass
> Just x. If you don't, you pass Nothing, annotated to the appropriate
> type. A situation where you may or may not have a value is exactly
> what Maybe is for, so it's not a hack. :-)
> This is better than the Proxy approach because it lets typeRep have
> the functionality of typeOf -- typeOf x = typeRep (Just x) -- which it
> doesn't with plain Proxy. It's also better because Maybe is a Prelude
> type suited to the purpose which everybody already knows.
> (Of course typeRep can keep the polymorphic type, which would make it
> Proxy-compatible. But we don't need to put Proxy in base, or re-export
> it from Data.Typeable, or even mention it in the documentation.)

I don't think it's possible. Proxy has to be kind-polymorphic, so that
we can apply it to type constructors, constraints etc.

But Maybe can't be kind-polymorphic, because it has a field of type 'a'.
Thus, the kind of 'a' is forced to be *.

Another problem with this approach is that it's not self-documenting.
You have to say specifically that this argument is just a proxy and the
semantics will be the same regardless of what you pass.

But it was an interesting idea nevertheless.


More information about the Libraries mailing list