@@ -67,24 +67,25 @@ compileArgs flags =
6767
6868type Interface = String
6969
70+file :: Flags -> FilePath -> String -> FilePath
71+file flags filePath ext = output_directory flags </> replaceExtension filePath ext
72+
73+elmo :: Flags -> FilePath -> FilePath
74+elmo flags filePath = file flags filePath "elmo"
75+
76+
7077buildFile :: Flags -> Int -> Int -> FilePath -> IO Interface
7178buildFile flags moduleNum numModules filePath =
7279 do compiled <- alreadyCompiled
73− if compiled then readFile elmo else compile
80+ if compiled then readFile (elmo flags filePath) else compile
7481
7582 where
76− file :: String -> FilePath
77− file ext = output_directory flags </> replaceExtension filePath ext
78−
79− elmo :: FilePath
80− elmo = file "elmo"
81−
8283 alreadyCompiled :: IO Bool
8384 alreadyCompiled = do
84− exists <- doesFileExist elmo
85+ exists <- doesFileExist (elmo flags filePath)
8586 if not exists then return False
8687 else do tsrc <- getModificationTime filePath
87− tint <- getModificationTime elmo
88+ tint <- getModificationTime (elmo flags filePath)
8889 return (tsrc < tint)
8990
9091 number :: String
@@ -104,7 +105,7 @@ buildFile flags moduleNum numModules filePath =
104105 Right modul -> do exs <- exportInfo modul
105106 return (exs, jsModule modul)
106107 createDirectoryIfMissing True (output_directory flags)
107− writeFile elmo obj
108+ writeFile (elmo flags filePath) obj
108109 return obj
109110
110111
@@ -122,19 +123,19 @@ build flags rootFile = do
122123 case only_js flags of
123124 True -> do
124125 putStr "Generating JavaScript ... "
125− writeFile (replaceExtension rootFile "js") (genJs js)
126+ writeFile (file flags rootFile "js") (genJs js)
126127 putStrLn "Done"
127128 False -> do
128129 putStr "Generating HTML ... "
129130 runtime <- getRuntime flags
130131 let html = genHtml $ createHtml runtime rootFile (sources js) ""
131− writeFile (replaceExtension rootFile "html") html
132+ writeFile (file flags rootFile "html") html
132133 putStrLn "Done"
133134
134135 where
135136 appendToOutput :: String -> FilePath -> IO String
136137 appendToOutput js filePath =
137− do src <- readFile (output_directory flags </> replaceExtension filePath "elmo")
138+ do src <- readFile (elmo flags filePath)
138139 return (src ++ js)
139140
140141 genHtml = if minify flags then Normal.renderHtml else Pretty.renderHtml
@@ -153,6 +154,6 @@ buildFiles flags numModules interfaces (filePath:rest) = do
153154
154155
155156exportInfo :: Module -> IO String
156−exportInfo (Module names ims exs stmts) =
157+exportInfo (Module names exs ims stmts) =
157158 do print exs
158159 return (show exs)