+outputableToString :: Outputable.Outputable a => a -> Prelude.String
+outputableToString = (\x -> Outputable.showSDocDebug (Outputable.ppr x))
+
+coreViewDeep :: Type.Type -> Type.Type
+coreViewDeep t =
+ case t of
+ TypeRep.TyVarTy tv -> TypeRep.TyVarTy tv
+ TypeRep.FunTy arg res -> TypeRep.FunTy (coreViewDeep arg) (coreViewDeep res)
+ TypeRep.AppTy fun arg -> TypeRep.AppTy (coreViewDeep fun) (coreViewDeep arg)
+ TypeRep.ForAllTy fun arg -> TypeRep.ForAllTy fun (coreViewDeep arg)
+ TypeRep.TyConApp tc tys -> let t' = TypeRep.TyConApp tc (Prelude.map coreViewDeep tys)
+ in case Type.coreView t' of
+ Prelude.Nothing -> t'
+ Prelude.Just t'' -> t''
+ TypeRep.PredTy p -> case Type.coreView t of
+ Prelude.Nothing -> TypeRep.PredTy p
+ Prelude.Just t' -> t'
+
+coreCoercionToWeakCoercion :: Type.Type -> WeakCoercion
+coreCoercionToWeakCoercion c =
+ WCoUnsafe (errOrFail (coreTypeToWeakType t1)) (errOrFail (coreTypeToWeakType t2))
+ where
+ (t1,t2) = Coercion.coercionKind c
+{-
+-- REMEMBER: cotycon applications may be oversaturated
+ case c of
+ TypeRep.TyVarTy v -> WCoVar (WeakCoerVar v (Prelude.error "FIXME") (Prelude.error "FIXME") (Prelude.error "FIXME"))
+ TypeRep.AppTy t1 t2 -> WCoApp (coreCoercionToWeakCoercion t1) (coreCoercionToWeakCoercion t2)
+ TypeRep.TyConApp tc t ->
+ case TyCon.isCoercionTyCon_maybe tc of
+ Prelude.Nothing -> Prelude.error ((Prelude.++) "coreCoercionToWeakCoercion got isCoercionTyCon_maybe " (outputableToString c))
+ Prelude.Just (_, ctcd) ->
+ case (ctcd,t) of
+ (TyCon.CoTrans , [x,y] ) -> WCoComp (coreCoercionToWeakCoercion x) (coreCoercionToWeakCoercion y)
+ (TyCon.CoSym , [x] ) -> WCoSym (coreCoercionToWeakCoercion x)
+ (TyCon.CoLeft , [x] ) -> WCoLeft (coreCoercionToWeakCoercion x)
+ (TyCon.CoRight , [x] ) -> WCoLeft (coreCoercionToWeakCoercion x)
+-- (TyCon.CoUnsafe, [t1, t2 ] ) -> WCoUnsafe (coreTypeToWeakType t1) (coreTypeToWeakType t2)
+ (TyCon.CoTrans , [] ) -> Prelude.error "CoTrans is not in post-publication-appendix SystemFC1"
+ (TyCon.CoCsel1 , [] ) -> Prelude.error "CoCsel1 is not in post-publication-appendix SystemFC1"
+ (TyCon.CoCsel2 , [] ) -> Prelude.error "CoCsel2 is not in post-publication-appendix SystemFC1"
+ (TyCon.CoCselR , [] ) -> Prelude.error "CoCselR is not in post-publication-appendix SystemFC1"
+ (TyCon.CoInst , [] ) -> Prelude.error "CoInst is not in post-publication-appendix SystemFC1"
+ (TyCon.CoAxiom _ _ _ , _ ) -> Prelude.error "CoAxiom is not yet implemented (FIXME)"
+ ( _, [ t1 , t2 ]) -> WCoUnsafe (errOrFail (coreTypeToWeakType t1)) (errOrFail (coreTypeToWeakType t2))
+ _ -> Prelude.error ((Prelude.++) "coreCoercionToWeakCoercion got " (outputableToString c))
+ _ -> Prelude.error ((Prelude.++) "coreCoercionToWeakCoercion got " (outputableToString c))
+-}
+-- TypeRep.ForAllTy v t -> WCoAll (Prelude.error "FIXME") (coreTypeToWeakType t)
+-- FIXME x y -> WCoAppT (coreCoercionToWeakCoercion x) (coreCoercionToWeakType y)
+-- CoreSyn.Type t -> WCoType (coreTypeToWeakType t)
+
+{-
+weakCoercionToCoreCoercion :: CoreCoercion -> Type.Type
+| WCoVar (weakCoerVar _ _ t1 t2) => (t1,t2)
+| WCoType t => Prelude_error "FIXME WCoType"
+| WCoApp c1 c2 => Prelude_error "FIXME WCoApp"
+| WCoAppT c t => Prelude_error "FIXME WCoAppT"
+| WCoAll k f => Prelude_error "FIXME WCoAll"
+| WCoSym c => let (t2,t1) := weakCoercionTypes c in (t1,t2)
+| WCoComp c1 c2 => Prelude_error "FIXME WCoComp"
+| WCoLeft c => Prelude_error "FIXME WCoLeft"
+| WCoRight c => Prelude_error "FIXME WCoRight"
+| WCoUnsafe t1 t2 => (t1,t2)