git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Remove escape check
commit9eff66330ae3b2cbeeaa09c93cef080b3bc1aa45 authorPhil Freeman <paf31@cantab.net> dateSun 16 Mar 2014, 15:43 (13 years ago) parent7fe90c8
1 file changed+1−24
src/Language/PureScript/TypeChecker/Types.hs+1−24
src/Language/PureScript/TypeChecker/Types.hs+1−24
@@ -182,7 +182,7 @@ typesOf mainModuleName moduleName vals = do
182182 -- If the declaration is a function, it has access to other values in the binding group.
183183 -- If not, the generated code might fail at runtime since those values might be undefined.
184184 let dict' = if isFunction val then dict else M.empty
185− triple@(_, (val', ty)) <- case e of
185+ triple@(_, (_, ty)) <- case e of
186186 -- Typed declarations
187187 (ident, (val', Just (ty, checkType))) -> do
188188 -- Kind check
@@ -204,8 +204,6 @@ typesOf mainModuleName moduleName vals = do
204204 when (Just moduleName == mainModuleName && fst e == Ident C.main) $ do
205205 [eff, a] <- replicateM 2 fresh
206206 ty =?= TypeApp (TypeApp (TypeConstructor (Qualified (Just (ModuleName [ProperName "Control", ProperName "Monad", ProperName "Eff"])) (ProperName "Eff"))) eff) a
207− -- Make sure unification variables do not escape
208− escapeCheck val' ty
209207 return triple
210208 forM tys $ \(ident, (val, ty)) -> do
211209 -- Replace type class dictionary placeholders with actual dictionaries
@@ -314,27 +312,6 @@ typeHeadsAreEqual m e (SaturatedTypeSynonym name args) t2 = case expandTypeSynon
314312 Right t1 -> typeHeadsAreEqual m e t1 t2
315313typeHeadsAreEqual _ _ _ _ = Nothing
316314
317−-- |
318−-- Ensure unsolved unification variables do not escape
319−--
320−escapeCheck :: Value -> Type -> UnifyT Type Check ()
321−escapeCheck value ty = do
322− subst <- unifyCurrentSubstitution <$> UnifyT get
323− let visibleUnknowns = nub $ unknowns $ subst $? ty
324− let allUnknowns = findAllTypes value
325− forM_ allUnknowns $ \t -> do
326− let unsolvedUnknowns = nub . unknowns $ subst $? t
327− guardWith "An unsolved type variable disappeared during type checking." $ null $ unsolvedUnknowns \\ visibleUnknowns
328−
329−-- |
330−-- Find all type annotations occuring inside a value
331−--
332−findAllTypes :: Value -> [Type]
333−findAllTypes = everything (++) (mkQ [] go)
334− where
335− go (TypedValue _ _ ty) = [ty]
336− go _ = []
337−
338315-- |
339316-- Ensure skolem variables do not escape their scope
340317--