<div dir="ltr"><div>I'm working on a GHC plugin in which I need to programmatically construct a coercion for an associated type, given the type function name and the type argument. For instance, I have the following class:<br>

<br>> class Encodable a where<br>>   type Encode a<br>>   encode :: a -> Encode a<br>>   decode :: Encode a -> a<br><br>along with a type instance, say `Int -> Bool`. In a GHC plugin, how can I apply a type function to an argument type to get back the resulting type and the associated coercion? (Given the latter, I think the former comes from `coercionKind`).<br>

<br></div>-- Conal<br></div>