on master help sign in
Make cross-module types aware of user-specified aliases
commit81522b306a1f44ef94aae67c61eeec5e5934bb52 authorEvan Czaplicki <info@elm-lang.org> dateMon 22 Jul 2013, 00:23 (13 years ago) parentc140d69
1 file changed+13−1
compiler/Type/Inference.hs+13−1
compiler/Type/Inference.hs+13−1
@@ -29,8 +29,20 @@ infer interfaces modul = unsafePerformIO $ do
2929 do (_, vars, tipe) <- Env.freshDataScheme env name
3030 return (name, (vars, tipe))
3131
32+ let combine name importMethod interface =
33+ let tipes = iTypes interface in
34+ case importMethod of
35+ As alias -> Map.mapKeys (\v -> alias ++ "." ++ v) tipes
36+ Hiding hidens -> foldr Map.delete tipes hidens
37+ Importing visibles ->
38+ Map.intersection tipes (Map.fromList [ (v,()) | v <- visibles ])
39+
40+ locals = Map.intersectionWithKey combine (Map.fromList (imports modul)) interfaces
41+
42+ mapM print (imports modul)
43+
3244 importedVars <-
33− forM (concatMap (Map.toList . iTypes) $ Map.elems interfaces) $ \(name,tipe) ->
45+ forM (concatMap Map.toList $ Map.elems locals) $ \(name,tipe) ->
3446 (,) name `fmap` Env.instantiateTypeWithContext env tipe Map.empty
3547
3648 let allTypes = ctors ++ importedVars