on master help sign in
Get rid of dead function and give instantiateTypeWithContext a shorter name
0681fbeEvan Czaplicki
compiler/Type/Constrain/Expression.hs+1−1
@@ -185,7 +185,7 @@ constrainDef env info (pattern, expr, maybeTipe) =
185 do flexiVars <- mapM (\_ -> var Flexible) qs
185 do flexiVars <- mapM (\_ -> var Flexible) qs
186 let inserts = zipWith (\arg typ -> Map.insert arg (VarN typ)) qs flexiVars
186 let inserts = zipWith (\arg typ -> Map.insert arg (VarN typ)) qs flexiVars
187 env' = env { Env.value = List.foldl' (\x f -> f x) (Env.value env) inserts }
187 env' = env { Env.value = List.foldl' (\x f -> f x) (Env.value env) inserts }
188− (vars, typ) <- Env.instantiateTypeWithContext env tipe Map.empty
188+ (vars, typ) <- Env.instantiateType env tipe Map.empty
189 let scheme = Scheme { rigidQuantifiers = [],
189 let scheme = Scheme { rigidQuantifiers = [],
190 flexibleQuantifiers = flexiVars ++ vars,
190 flexibleQuantifiers = flexiVars ++ vars,
191 constraint = CTrue,
191 constraint = CTrue,
compiler/Type/Environment.hs+3−10
@@ -102,16 +102,9 @@ get env subDict key = Map.findWithDefault err key (subDict env)
102freshDataScheme :: Environment -> String -> IO (Int, [Variable], [Type], Type)
102freshDataScheme :: Environment -> String -> IO (Int, [Variable], [Type], Type)
103freshDataScheme env name = get env constructor name
103freshDataScheme env name = get env constructor name
104
104
105−
106−instantiateType :: Environment -> Src.Type -> IO Type
105+instantiateType ::
107−instantiateType env sourceType =
108− snd <$> instantiateTypeWithContext env sourceType Map.empty
109−
110−instantiateTypeWithContext :: Environment
111− -> Src.Type
112− -> Map.Map String Variable
106+ Environment -> Src.Type -> Map.Map String Variable -> IO ([Variable], Type)
113− -> IO ([Variable], Type)
114−instantiateTypeWithContext env sourceType dict =
107+instantiateType env sourceType dict =
115 do (tipe, dict') <- State.runStateT (instantiator env sourceType) dict
108 do (tipe, dict') <- State.runStateT (instantiator env sourceType) dict
116 return (Map.elems dict', tipe)
109 return (Map.elems dict', tipe)
117
110
compiler/Type/Inference.hs+1−1
@@ -47,7 +47,7 @@ infer interfaces' modul = unsafePerformIO $ do
47
47
48 importedVars <-
48 importedVars <-
49 forM (concatMap Map.toList $ Map.elems locals) $ \(name,tipe) ->
49 forM (concatMap Map.toList $ Map.elems locals) $ \(name,tipe) ->
50− (,) name `fmap` Env.instantiateTypeWithContext env tipe Map.empty
50+ (,) name `fmap` Env.instantiateType env tipe Map.empty
51
51
52 let allTypes = ctors ++ importedVars
52 let allTypes = ctors ++ importedVars
53 vars = concatMap (fst . snd) allTypes
53 vars = concatMap (fst . snd) allTypes