* Remove trace from optCoercion
* Use simplCoercion for type arguments in the Simplifier
(because they might be coercions)
simplExprF' env (Type ty) cont
= ASSERT( contIsRhsOrArg cont )
simplExprF' env (Type ty) cont
= ASSERT( contIsRhsOrArg cont )
- do { ty' <- simplType env ty
+ do { ty' <- simplCoercion env ty
; rebuild env (Type ty') cont }
simplExprF' env (Case scrut bndr _ alts) cont
; rebuild env (Type ty') cont }
simplExprF' env (Case scrut bndr _ alts) cont
---------------------------------
simplCoercion :: SimplEnv -> InType -> SimplM OutType
---------------------------------
simplCoercion :: SimplEnv -> InType -> SimplM OutType
+-- The InType isn't *necessarily* a coercion, but it might be
+-- (in a type application, say) and optCoercion is a no-op on types
simplCoercion env co
= do { co' <- simplType env co
; return (optCoercion co') }
simplCoercion env co
= do { co' <- simplType env co
; return (optCoercion co') }
| otherwise = mkCoerce co expr
rebuildCall env fun info (ApplyTo _ (Type arg_ty) se cont)
| otherwise = mkCoerce co expr
rebuildCall env fun info (ApplyTo _ (Type arg_ty) se cont)
- = do { ty' <- simplType (se `setInScope` env) arg_ty
+ = do { ty' <- simplCoercion (se `setInScope` env) arg_ty
; rebuildCall env (fun `App` Type ty') info cont }
rebuildCall env fun
; rebuildCall env (fun `App` Type ty') info cont }
rebuildCall env fun
\begin{code}
optCoercion :: Coercion -> Coercion
optCoercion co
\begin{code}
optCoercion :: Coercion -> Coercion
optCoercion co
- = pprTrace "optCoercion" (ppr co $$ ppr (coercionKind co) $$ text ">-->" $$ ppr result) $
- ASSERT2( coercionKind co `eq` coercionKind result, ppr co $$ ppr result $$ ppr (coercionKind co) $$ ppr (coercionKind result) )
+ = ASSERT2( coercionKind co `eq` coercionKind result,
+ ppr co $$ ppr result $$ ppr (coercionKind co) $$ ppr (coercionKind result) )
result
where
(s1,t1) `eq` (s2,t2) = s1 `coreEqType` s2 && t1 `coreEqType` t2
result
where
(s1,t1) `eq` (s2,t2) = s1 `coreEqType` s2 && t1 `coreEqType` t2