Proxy and new-typeable

José Pedro Magalhães jpm at cs.uu.nl
Thu Feb 7 16:02:15 CET 2013


Yes, it's entirely unproblematic, and a good suggestion.


Thanks,
Pedro

On Sat, Jan 26, 2013 at 6:36 PM, Simon Peyton-Jones
<simonpj at microsoft.com>wrote:

> Good idea!  Simple, and I see no downsides.
>
> Pedro is putting in place a new Typeable library (using kind polymorphism)
> for GHC 7.8.  Pedro, might you incorporate this?
>
> Simon
>
> |  -----Original Message-----
> |  From: libraries-bounces at haskell.org [mailto:
> libraries-bounces at haskell.org] On
> |  Behalf Of Shachaf Ben-Kiki
> |  Sent: 26 January 2013 04:07
> |  To: libraries at haskell.org
> |  Subject: Proxy and new-typeable
> |
> |  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 haskell.org
> |  http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20130207/53574f86/attachment.htm>


More information about the Libraries mailing list