git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Remove escape check
9eff663Phil Freeman
src/Language/PureScript/TypeChecker/Types.hs+1−24
@@ -182,7 +182,7 @@ typesOf mainModuleName moduleName vals = do
182 -- If the declaration is a function, it has access to other values in the binding group.
182 -- If the declaration is a function, it has access to other values in the binding group.
183 -- If not, the generated code might fail at runtime since those values might be undefined.
183 -- If not, the generated code might fail at runtime since those values might be undefined.
184 let dict' = if isFunction val then dict else M.empty
184 let dict' = if isFunction val then dict else M.empty
185− triple@(_, (val', ty)) <- case e of
185+ triple@(_, (_, ty)) <- case e of
186 -- Typed declarations
186 -- Typed declarations
187 (ident, (val', Just (ty, checkType))) -> do
187 (ident, (val', Just (ty, checkType))) -> do
188 -- Kind check
188 -- Kind check
@@ -204,8 +204,6 @@ typesOf mainModuleName moduleName vals = do
204 when (Just moduleName == mainModuleName && fst e == Ident C.main) $ do
204 when (Just moduleName == mainModuleName && fst e == Ident C.main) $ do
205 [eff, a] <- replicateM 2 fresh
205 [eff, a] <- replicateM 2 fresh
206 ty =?= TypeApp (TypeApp (TypeConstructor (Qualified (Just (ModuleName [ProperName "Control", ProperName "Monad", ProperName "Eff"])) (ProperName "Eff"))) eff) a
206 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
209 return triple
207 return triple
210 forM tys $ \(ident, (val, ty)) -> do
208 forM tys $ \(ident, (val, ty)) -> do
211 -- Replace type class dictionary placeholders with actual dictionaries
209 -- Replace type class dictionary placeholders with actual dictionaries
@@ -314,27 +312,6 @@ typeHeadsAreEqual m e (SaturatedTypeSynonym name args) t2 = case expandTypeSynon
314 Right t1 -> typeHeadsAreEqual m e t1 t2
312 Right t1 -> typeHeadsAreEqual m e t1 t2
315typeHeadsAreEqual _ _ _ _ = Nothing
313typeHeadsAreEqual _ _ _ _ = Nothing
316
314
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−
338-- |
315-- |
339-- Ensure skolem variables do not escape their scope
316-- Ensure skolem variables do not escape their scope
340--
317--