[project @ 2002-04-22 11:50:21 by simonpj]
authorsimonpj <unknown>
Mon, 22 Apr 2002 11:50:21 +0000 (11:50 +0000)
committersimonpj <unknown>
Mon, 22 Apr 2002 11:50:21 +0000 (11:50 +0000)
Do forall-hoisting recursively

ghc/compiler/typecheck/TcType.lhs

index 27abbd5..d498e7b 100644 (file)
@@ -737,10 +737,13 @@ hoistForAllTys ty
     hoist orig_ty (ForAllTy tv ty) = case hoist ty ty of
                                        (tvs,theta,tau) -> (tv:tvs,theta,tau)
     hoist orig_ty (FunTy arg res)
-       | isPredTy arg             = case hoist res res of
-                                       (tvs,theta,tau) -> (tvs,arg:theta,tau)
+       | isPredTy arg'            = case hoist res res of
+                                       (tvs,theta,tau) -> (tvs,arg':theta,tau)
        | otherwise                = case hoist res res of
-                                       (tvs,theta,tau) -> (tvs,theta,mkFunTy arg tau)
+                                       (tvs,theta,tau) -> (tvs,theta,mkFunTy arg' tau)
+       where
+         arg' = hoistForAllTys arg     -- Don't forget to apply hoist recursively
+                                       -- to the argument type
 
     hoist orig_ty (NoteTy _ ty)    = hoist orig_ty ty
     hoist orig_ty ty              = ([], [], orig_ty)