getEqPredTys_maybe :: PredType -> Maybe (Role, Type, Type)
getEqPredTys_maybe ty
  = case splitTyConApp_maybe ty of
      Just (tc, [_, ty1, ty2])
        | tc `hasKey` eqTyConKey -> Just (Nominal, ty1, ty2)
        | tc `hasKey` coercibleTyConKey -> Just (Representational, ty1, ty2)
      _ -> Nothing
getEqPredTys_maybe :: PredType -> Maybe (Role, Type, Type)
getEqPredTys_maybe ty
  = case splitTyConApp_maybe ty of
      Just (tc, [_, ty1, ty2])
        | tc `hasKey` eqTyConKey -> Just (Nominal, ty1, ty2)
        | tc `hasKey` coercibleTyConKey -> Just (Representational, ty1, ty2)
      _ -> Nothing
getEqPredTys_maybe ty
  = case splitTyConApp_maybe ty of
      Just (tc, [_, ty1, ty2])
        | tc `hasKey` eqTyConKey -> Just (Nominal, ty1, ty2)
        | tc `hasKey` coercibleTyConKey -> Just (Representational, ty1, ty2)
      _ -> Nothing