Can't eta-reduce representational coercions
When I say
import Data.Type.Coercion
import Data.Coerce
import Data.Proxy
eta2 :: Coercible (f a) (g a) => Proxy a -> Coercion f g
eta2 _ = Coercion
I get
Could not coerce from ‘f’ to ‘g’
because ‘f’ and ‘g’ are different types.
arising from a use of ‘Coercion’
from the context (Coercible (f a) (g a))
bound by the type signature for
eta2 :: Coercible (f a) (g a) => Proxy a -> Coercion f g
at /Users/rae/temp/Roles.hs:5:9-56
In the expression: Coercion
In an equation for ‘eta2’: eta2 _ = Coercion
Unlike the case for #9117 (closed), this one is not expressible in Core. (At least, I don't see a way to do it.) So, to do this, we would have to update Core and then update the constraint solver. I do think this would be type safe. But, I also think it's reasonable to wait for someone with a real use case to shout before doing this. The only use case I have is to be able to do this:
-- says that a's parameter is representational
class Rep (a :: k1 -> k2) where
co :: Coercible x y => Coercible (a x) (a x)
instance Rep f => Rep (Compose f) where ...