I'm pretty sure this isn't sufficient. But it feels darn close.
ext3 :: (Data a, Typeable3 t)
=> c a
-> (forall d1 d2 d3. c (t d1 d2 d3))
-> c a
ext3 def ext = maybe def (id) (gcast3' ext)
gcast3' :: (Typeable3 t, Data a) => c (t f g h) -> Maybe (c a)
gcast3' x = r
where
r = if typeOf3 (getArg x) == typeOf3' (getArg (fromJust r))
then Just $ unsafeCoerce x
else Nothing
getArg :: c x -> x
getArg = undefined
typeOf3' z = mkTyConApp (typeRepTyCon (typeOf z)) []