on master help sign in
Get working with latest definition of Modules
commitb4fbfde8fcc73852c0e3f9349f1cda1e52dbb851 authorEvan Czaplicki <info@elm-lang.org> dateWed 30 Apr 2014, 08:36 (13 years ago) parent3902049
1 file changed+6−6
compiler/Type/Inference.hs+6−6
compiler/Type/Inference.hs+6−6
@@ -24,9 +24,9 @@ import System.IO.Unsafe -- Possible to switch over to the ST monad instead of
2424
2525infer :: Interfaces -> CanonicalModule -> Either [Doc] (Map.Map String CanonicalType)
2626infer interfaces modul = unsafePerformIO $ do
27− env <- Env.initialEnvironment
28− (datatypes modul ++ concatMap iAdts (Map.elems interfaces))
29− (aliases modul ++ concatMap iAliases (Map.elems interfaces))
27+ let moduleBody = body modul
28+ adts = Map.unions (datatypes moduleBody : map iAdts (Map.elems interfaces))
29+ env <- Env.initialEnvironment adts
3030 ctors <- forM (Map.keys (Env.constructor env)) $ \name ->
3131 do (_, vars, args, result) <- Env.freshDataScheme env name
3232 return (name, (vars, foldr (T.==>) result args))
@@ -42,16 +42,16 @@ infer interfaces modul = unsafePerformIO $ do
4242 environ = noneNoDocs . T.CLet [ T.Scheme vars [] (noneNoDocs T.CTrue) header ]
4343
4444 fvar <- liftIO $ T.var T.Flexible
45− c <- TcExpr.constrain env (program modul) (T.VarN fvar)
45+ c <- TcExpr.constrain env (program moduleBody) (T.VarN fvar)
4646 return (header, environ c)
4747
4848 case attemptConstraint of
4949 Left err -> return $ Left err
5050 Right (header, constraint) -> do
5151 state <- execStateT (Solve.solve constraint) TS.initialState
52− let rules = Alias.rules interfaces (aliases modul) (imports modul)
52+ let rules = Alias.rules interfaces (aliases moduleBody) (imports modul)
5353 case TS.sErrors state of
5454 errors@(_:_) -> Left `fmap` sequence (map ($ rules) (reverse errors))
55− [] -> case Check.portTypes rules (program modul) of
55+ [] -> case Check.portTypes rules (program moduleBody) of
5656 Right () -> Check.mainType rules (Map.difference (TS.sSavedEnv state) header)
5757 Left err -> return (Left err)