+ -- predicate type => handle like a datatype constructor application
+ go (PredTy (ClassP cls tys))
+ = do { (tys', ctys, tys_eqss) <- mapAndUnzip3M go tys
+ ; let tys_eqs = concat tys_eqss
+ ; if null tys_eqs
+ then -- unchanged, keep the old type with folded synonyms
+ return (ty, ty, [])
+ else
+ return (PredTy (ClassP cls tys'),
+ PredTy (ClassP cls ctys),
+ tys_eqs)
+ }
+
+ -- implicit parameter => flatten subtype
+ go ty@(PredTy (IParam ipn ity))
+ = do { (ity', co, eqs) <- go ity
+ ; if null eqs
+ then return (ty, ty, [])
+ else return (PredTy (IParam ipn ity'),
+ PredTy (IParam ipn co),
+ eqs)
+ }
+
+ -- we should never see a equality
+ go (PredTy (EqPred _ _))
+ = panic "TcTyFuns.flattenType: malformed type"