<div>Consider</div><div><br></div><div>newtype Foo = Foo Int</div>
<div><br></div><div>lift :: (Int -> a) -> Foo -> a</div><div>lift f (Foo x) = f x</div><div><br></div><div>Now, I'd expect this to compile with -O2 down to something like</div><div><br></div><div>lift f = f `cast` (Foo -> a)</div>
<div><br></div><div>but it doesn't.</div><div><br></div><div>It seems that GeneralizedNewtypeDeriving assumes that these two things *are* equivalent, and it just directly casts the class dictionary. The implication would be that that GeneralizedNewtypeDeriving gives more efficient instances than you could *possibly* get if you wrote them by hand, which is very sad.</div>
<div><br clear="all">Louis Wasserman<br><a href="mailto:wasserman.louis@gmail.com" target="_blank">wasserman.louis@gmail.com</a><br><a href="http://profiles.google.com/wasserman.louis" target="_blank">http://profiles.google.com/wasserman.louis</a><br>
</div>