From 81522b306a1f44ef94aae67c61eeec5e5934bb52 Mon Sep 17 00:00:00 2001 From: Evan Czaplicki Date: Mon, 22 Jul 2013 00:23:26 +0200 Subject: [PATCH] Make cross-module types aware of user-specified aliases --- compiler/Type/Inference.hs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/compiler/Type/Inference.hs b/compiler/Type/Inference.hs index 763c9df..f899576 100644 --- a/compiler/Type/Inference.hs +++ b/compiler/Type/Inference.hs @@ -29,8 +29,20 @@ infer interfaces modul = unsafePerformIO $ do do (_, vars, tipe) <- Env.freshDataScheme env name return (name, (vars, tipe)) + let combine name importMethod interface = + let tipes = iTypes interface in + case importMethod of + As alias -> Map.mapKeys (\v -> alias ++ "." ++ v) tipes + Hiding hidens -> foldr Map.delete tipes hidens + Importing visibles -> + Map.intersection tipes (Map.fromList [ (v,()) | v <- visibles ]) + + locals = Map.intersectionWithKey combine (Map.fromList (imports modul)) interfaces + + mapM print (imports modul) + importedVars <- - forM (concatMap (Map.toList . iTypes) $ Map.elems interfaces) $ \(name,tipe) -> + forM (concatMap Map.toList $ Map.elems locals) $ \(name,tipe) -> (,) name `fmap` Env.instantiateTypeWithContext env tipe Map.empty let allTypes = ctors ++ importedVars