on master help sign in
only expose exported values, add comments
commit6a7c0d6384fc28f6c83c22f15100652368598d81 authorEvan Czaplicki <info@elm-lang.org> dateWed 28 May 2014, 19:12 (12 years ago) parenteae58a7
1 file changed+9−2
compiler/Build/Source.hs+9−2
compiler/Build/Source.hs+9−2
@@ -4,7 +4,7 @@ module Build.Source (build) where
44import qualified Data.Map as Map
55import Text.PrettyPrint (Doc)
66
7−import AST.Module
7+import AST.Module as Module
88import qualified Parse.Parse as Parse
99import qualified Metadata.Prelude as Prelude
1010import qualified Transform.Check as Check
@@ -16,14 +16,21 @@ build noPrelude interfaces source =
1616 do let infixes = Map.fromList . map (\(assoc,lvl,op) -> (op,(lvl,assoc)))
1717 . concatMap iFixities $ Map.elems interfaces
1818
19+ -- Parse the source code and validate that it is well formed.
1920 validModule <- do
2021 modul <- Prelude.add noPrelude `fmap` Parse.program infixes source
2122 case Check.mistakes (body modul) of
2223 [] -> return modul
2324 ms -> Left ms
2425
26+ -- Canonicalize all variables, pinning down where they came from.
2527 canonicalModule <- Canonical.module' interfaces validModule
2628
29+ -- Run type inference on the program.
2730 types <- TI.infer interfaces canonicalModule
2831
29− return $ canonicalModule { body = (body canonicalModule) { types = types } }
32+ -- Trim down the set of exported values to the stuff that is actually exported.
33+ let types' = Canonical.filterExports types (Module.exports canonicalModule)
34+ body' = (body canonicalModule) { types = types' }
35+
36+ return $ canonicalModule { body = body' }