on master help sign in
Switch from [Def t v] to (LExpr t v) for program representation
commitb0f96a2eabce2b0a946676fc567acaf31bf474b8 authorEvan Czaplicki <info@elm-lang.org> dateFri 19 Jul 2013, 18:02 (13 years ago) parent4dc68ac
2 files changed+7−7
compiler/SourceSyntax/Module.hs+1−1 compiler/Type/Inference.hs+6−6
compiler/SourceSyntax/Module.hs+1−1
@@ -26,7 +26,7 @@ data MetadataModule t v = MetadataModule {
2626 path :: FilePath,
2727 exports :: [String],
2828 imports :: [(String, ImportMethod)],
29− defs :: [Def t v],
29+ program :: LExpr t v,
3030 types :: Map.Map String T.Variable,
3131 fixities :: [(Assoc, Int, String)],
3232 aliases :: [(String, [String], Type)],
compiler/Type/Inference.hs+6−6
@@ -10,6 +10,7 @@ import qualified Type.Solve as Solve
1010
1111import SourceSyntax.Module
1212import qualified SourceSyntax.Expression as Expr
13+import SourceSyntax.PrettyPrint
1314import Text.PrettyPrint
1415import qualified Type.State as TS
1516import Control.Monad.State
@@ -28,14 +29,13 @@ infer modul = unsafePerformIO $ do
2829 do (_, vars, tipe) <- Env.freshDataScheme env name
2930 return (name, (vars, tipe))
3031
31− let expr = Expr.dummyLet $ defs modul
32− vars = concatMap (fst . snd) ctors
32+ let vars = concatMap (fst . snd) ctors
3333 header = Map.map snd (Map.fromList ctors)
3434 environ = T.CLet [ T.Scheme vars [] T.CTrue header ]
35− constraint <- environ `fmap` TcExpr.constrain env expr (T.VarN var)
36− print =<< T.extraPretty constraint
37− (env,_,_,errors) <- execStateT (Solve.solve constraint) TS.initialState
35+ constraint <- environ `fmap` TcExpr.constrain env (program modul) (T.VarN var)
36+ state <- execStateT (Solve.solve constraint) TS.initialState
37+ let errors = TS.sErrors state
3838 if null errors
39− then return $ Right env
39+ then return $ Right (Map.difference (TS.sSavedEnv state) header)
4040 else Left `fmap` sequence errors
4141