on master help sign in
Update for new Module AST
commitaa7c2fdc6bcf3de2d6d49e5976d48e2ea14d15f9 authorEvan Czaplicki <info@elm-lang.org> dateWed 30 Apr 2014, 09:01 (13 years ago) parent724316a
1 file changed+13−14
compiler/Build/File.hs+13−14
compiler/Build/File.hs+13−14
@@ -23,8 +23,7 @@ import qualified Build.Source as Source
2323import qualified Build.Utils as Utils
2424import qualified Generate.JavaScript as JS
2525import qualified Parse.Module as Parser
26−import qualified AST.Module as M
27−import qualified Transform.Canonicalize as Canonical
26+import qualified AST.Module as Module
2827
2928-- Reader: Runtime flags, always accessible
3029-- Writer: Remember the last module to be accessed
@@ -33,10 +32,10 @@ type BuildT m a = RWST Flag.Flags (Last String) BInterfaces m a
3332type Build a = BuildT IO a
3433
3534-- Interfaces, remembering if something was recompiled
36−type BInterfaces = Map.Map String (Bool, M.ModuleInterface)
35+type BInterfaces = Map.Map String (Bool, Module.Interface)
3736
38−evalBuild :: Flag.Flags -> M.Interfaces -> Build ()
39− -> IO (Map.Map String M.ModuleInterface, Maybe String)
37+evalBuild :: Flag.Flags -> Module.Interfaces -> Build ()
38+ -> IO (Map.Map String Module.Interface, Maybe String)
4039evalBuild flags interfaces build =
4140 do (ifaces, moduleNames) <- execRWST build flags (fmap notUpdated interfaces)
4241 return (fmap snd ifaces, getLast moduleNames)
@@ -45,7 +44,7 @@ evalBuild flags interfaces build =
4544
4645-- | Builds a list of files, returning the moduleName of the last one.
4746-- Returns \"\" if the list is empty
48−build :: Flag.Flags -> M.Interfaces -> [FilePath] -> IO String
47+build :: Flag.Flags -> Module.Interfaces -> [FilePath] -> IO String
4948build flags interfaces files =
5049 do (ifaces, topName) <- evalBuild flags interfaces (buildAll files)
5150 let removeTopName = Maybe.maybe id Map.delete topName
@@ -56,7 +55,7 @@ build flags interfaces files =
5655 | null ports = return ()
5756 | otherwise = Print.failure msg
5857 where
59− ports = M.iPorts iface
58+ ports = Module.iPorts iface
6059 msg = concat
6160 [ "Port Error: ports may only appear in the main module, but\n"
6261 , " sub-module ", name, " declares the following port"
@@ -142,16 +141,16 @@ compile number filePath =
142141 createDirectoryIfMissing True (Flag.cache_dir flags)
143142 createDirectoryIfMissing True (Flag.build_dir flags)
144143
145− metaModule <-
144+ canonicalModule <-
146145 liftIO $ case Source.build (Flag.no_prelude flags) interfaces source of
147146 Right modul -> return modul
148147 Left errors -> do Print.errors errors
149148 exitFailure
150149
151− liftIO $ when (Flag.print_types flags) $ Print.metaTypes interfaces metaModule
150+ liftIO $ when (Flag.print_types flags) $ Print.moduleTypes interfaces canonicalModule
152151
153− let newInters = Canonical.interface name $ M.metaToInterface metaModule
154− generateCache name newInters metaModule
152+ let newInters = Module.toInterface canonicalModule
153+ generateCache name newInters canonicalModule
155154 update name newInters True
156155
157156 where
@@ -164,15 +163,15 @@ compile number filePath =
164163 , replicate (max 1 (20 - length name)) ' '
165164 , "( " ++ filePath ++ " )" ]
166165
167− generateCache name interfs metaModule = do
166+ generateCache name interfs canonicalModule = do
168167 flags <- ask
169168 liftIO $ do
170169 createDirectoryIfMissing True . dropFileName $ Utils.elmi flags filePath
171− writeFile (Utils.elmo flags filePath) (JS.generate metaModule)
170+ writeFile (Utils.elmo flags filePath) (JS.generate canonicalModule)
172171 withBinaryFile (Utils.elmi flags filePath) WriteMode $ \handle ->
173172 L.hPut handle (Binary.encode (name, interfs))
174173
175−update :: String -> M.ModuleInterface -> Bool -> Build ()
174+update :: String -> Module.Interface -> Bool -> Build ()
176175update name inter wasUpdated =
177176 do modify (Map.insert name (wasUpdated, inter))
178177 tell (Last . Just $ name)