Is there a way to determine if two types are coercible in template haskell?

Given their Name, it is possible to find whether or not it is possible to coerce between them. I’ve tried reifyInstances and isInstance which do not work.

1 Like

in what way does it not work?

I think it does not work because Coercible is special an instances are “generated” dynamically by the compiler. There is no predefined list of instances of Coercible.

I don’t know if there is another way to check coercibility with Template Haskell.

reifyInstance return an empty list and isInstance always return false like Typeable although the document did not mention it. From what jaror said, this seems to be generally impossible in template haskell.

The only solution I think of is to use reify to check the constructors of the two types and determine if the two are compatible, although this is quite tedious and seem fragile since future compiler changes might invalidate the implemented check.