Proxy and new-typeable

Roman Cheplyaka roma at
Sat Jan 26 09:27:50 CET 2013

Very nice idea! Thanks for bringing it up.

The only case I can see when this "proxyless" approach wouldn't work is
if Proxy ever has to be in a covariant position (e.g. returned by a
function). Then you'd need either a concrete proxy or an existential

If there are no such functions in the new Data.Typeable (which is very
plausible), then I'd prefer not to include Proxy into base, given that
it's already provided by an alternative package.


* Shachaf Ben-Kiki <shachaf at> [2013-01-25 20:07:10-0800]
> I see that the new-typeable branch in GHC is using "typeRep :: forall a.
> Typeable a => Proxy a -> TypeRep" rather than "typeOf :: forall a. Typeable a
> => a -> TypeRep". This is clearly a big improvement over using undefined
> everywhere.
> I'd like to suggest a small change, if it hasn't been brought up before --
> "typeRep :: forall proxy a. Typeable a => proxy a -> TypeRep". This makes
> typeRep compatible with any other Proxy type, since it doesn't use any
> properties of the concrete type -- it just uses it to pass information about
> the "a". Things that consume a Proxy don't ever need to refer to Proxy
> explicitly.
> This would make Typeable compatible with other Proxy libraries, like the one in
> "tagged". It would also make it compatible with any other type of kind * -> *
> -- for example, "typeRep ([] :: [Int])" would be a valid, and arguable more
> convenient, syntax for using typeRep. "Nothing :: Maybe Int" and so on would
> work too. So things that produce a "proxy" don't need to refer to Proxy
> explicitly either.
> Possibly this would make the Proxy type entirely unnecessary. If it stays,
> though, I suggest that it belongs in a module other than Data.Typeable.Internal
> -- it's a useful type for many other things, and as long as it's in base and
> exposed to users, it might as well be treated as a type in its own right. It's
> also a monad, can provide a variant of `asTypeOf`, and so on.
>     Shachaf
> _______________________________________________
> Libraries mailing list
> Libraries at

More information about the Libraries mailing list