Remove checkFreeness; no longer needed
authorsimonpj@microsoft.com <unknown>
Thu, 2 Sep 2010 23:32:27 +0000 (23:32 +0000)
committersimonpj@microsoft.com <unknown>
Thu, 2 Sep 2010 23:32:27 +0000 (23:32 +0000)
compiler/typecheck/TcMType.lhs

index 243fc85..4d6ced3 100644 (file)
@@ -40,7 +40,7 @@ module TcMType (
   --------------------------------
   -- Checking type validity
   Rank, UserTypeCtxt(..), checkValidType, checkValidMonoType,
-  SourceTyCtxt(..), checkValidTheta, checkFreeness,
+  SourceTyCtxt(..), checkValidTheta, 
   checkValidInstHead, checkValidInstance, 
   checkInstTermination, checkValidTypeInst, checkTyFamFreeness, checkKinds,
   checkUpdateMeta, updateMeta, checkTauTvUpdate, fillBoxWithTau, unifyKindCtxt,
@@ -1136,7 +1136,6 @@ check_type rank ubx_tup ty
                -- with a decent error message
        ; check_valid_theta SigmaCtxt theta
        ; check_type rank ubx_tup tau   -- Allow foralls to right of arrow
-       ; checkFreeness tvs theta
        ; checkAmbiguity tvs theta (tyVarsOfType tau) }
   where
     (tvs, theta, tau) = tcSplitSigmaTy ty
@@ -1490,28 +1489,6 @@ in each constraint is in V.  So we disallow a type like
 even in a scope where b is in scope.
 
 \begin{code}
-checkFreeness :: [Var] -> [PredType] -> TcM ()
-checkFreeness forall_tyvars theta
-  = do { flexible_contexts <- doptM Opt_FlexibleContexts
-       ; unless flexible_contexts $ mapM_ complain (filter is_free theta) }
-  where    
-    is_free pred     =  not (isIPPred pred)
-                    && not (any bound_var (varSetElems (tyVarsOfPred pred)))
-    bound_var ct_var = ct_var `elem` forall_tyvars
-    complain pred    = addErrTc (freeErr pred)
-
-freeErr :: PredType -> SDoc
-freeErr pred
-  = sep [ ptext (sLit "All of the type variables in the constraint") <+> 
-          quotes (pprPred pred)
-       , ptext (sLit "are already in scope") <+>
-          ptext (sLit "(at least one must be universally quantified here)")
-       , nest 4 $
-            ptext (sLit "(Use -XFlexibleContexts to lift this restriction)")
-        ]
-\end{code}
-
-\begin{code}
 checkThetaCtxt :: SourceTyCtxt -> ThetaType -> SDoc
 checkThetaCtxt ctxt theta
   = vcat [ptext (sLit "In the context:") <+> pprTheta theta,