On Mon, Feb 13, 2012 at 3:27 PM, Simon Marlow <span dir="ltr"><<a href="mailto:marlowsd@gmail.com">marlowsd@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 13/02/12 18:16, Edward Kmett wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You could probably get away with something like<br>
<br>
data Proxy = Proxy a<br>
<br>
class Typeable a where<br>
typeOfProxy :: Proxy a -> TypeRep<br>
<br>
typeOf :: forall a. Typeable a => a -> TypeRep<br>
typeOf = typeOfProxy (Proxy :: Proxy a)<br>
<br>
which being outside of the class won't contribute to the inference of<br>
'a's kind.<br>
<br>
This would let you retain the existing functionality.<br>
</blockquote>
<br></div>
Simon's version has this:<div class="im"><br>
typeOf :: forall a. Typeable a => a -> TypeRep<br></div>
typeOf x = typeRep (getType x) where<br>
getType :: a -> Proxy a<br>
getType _ = Proxy<br>
<br>
(your version is clearer, though)<br>
<br>
I'm assuming there's no significance behind your renaming of 'typeRep' to 'typeOfProxy'?<br></blockquote><div><br></div><div>No significance at all. I probably should have read the page before commenting. ;)</div>
<div><br></div><div>-Edward</div></div>