
On Mon, Feb 13, 2012 at 3:27 PM, Simon Marlow
On 13/02/12 18:16, Edward Kmett wrote:
You could probably get away with something like
data Proxy = Proxy a
class Typeable a where typeOfProxy :: Proxy a -> TypeRep
typeOf :: forall a. Typeable a => a -> TypeRep typeOf = typeOfProxy (Proxy :: Proxy a)
which being outside of the class won't contribute to the inference of 'a's kind.
This would let you retain the existing functionality.
Simon's version has this:
typeOf :: forall a. Typeable a => a -> TypeRep typeOf x = typeRep (getType x) where getType :: a -> Proxy a getType _ = Proxy
(your version is clearer, though)
I'm assuming there's no significance behind your renaming of 'typeRep' to 'typeOfProxy'?
No significance at all. I probably should have read the page before commenting. ;) -Edward