<div dir="ltr"><div class="gmail_quote"><div dir="ltr">Given that Coercible instances are Deeply Magical, perhaps I'm being a bit naive here, but I recently tried to write a TH function that can check if one type is a newtype of another (or a newtype of a newtype of another, etc).<div><br></div><font face="monospace, monospace">coercibleToFrom :: Type -> Type -> Q Bool<br>coercibleToFrom tx ty = (&&) <$> isInstance ''Coercible [tx, ty]<br>                             <*> isInstance ''Coercible [ty, tx]</font><br><div><font face="monospace, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">If this worked as I'd hoped, I'm almost certain checking reflexively is redundant. However, I can't seem to get reifyInstances to ever return an InstanceDec for a Coercible instance. Given that these instances are generated on the fly by the typechecker, there's no way to make them available at TH runtime, correct? And, given that, is there an easy way to find out with TH whether not I'll be able to use coerce without taking all the Decs apart to hunt for NewtypeD?</font></div><span class="HOEnZb"><font color="#888888"><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Travis</font></div></font></span></div>
</div><br></div>