I'm a big fan of this!

There aren't any covariant occurrences of Proxy in the Typeable use-case. So it really doesn't need an explicit Proxy type at all.

Both the tagged and reflection packages go out of their way to make all contravariant uses agnostic about the proxy type. This rather dramatically cuts down on the amount of ScopedTypeVariable noise I need to use in my code, because I can often just pass a container holding values of the correct type directly as my "Proxy" when I have one.

-Edward

On Sat, Jan 26, 2013 at 3:27 AM, Roman Cheplyaka <roma@ro-che.info> wrote:
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
wrapper.

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.

Roman

* Shachaf Ben-Kiki <shachaf@gmail.com> [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@haskell.org
> http://www.haskell.org/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries