on master help sign in
Do some house keeping in the Compiler.hs file. Start using the `System.FilePath` module which cleaned up some code and is probably significantly safer :)
fb3acd7evancz
elm/Elm.cabal+4−2
@@ -72,7 +72,8 @@ Library
72 pandoc <= 1.9.4.2,
72 pandoc <= 1.9.4.2,
73 bytestring,
73 bytestring,
74 hjsmin,
74 hjsmin,
75− indents
75+ indents,
76+ filepath
76
77
77Executable elm
78Executable elm
78 Main-is: Compiler.hs
79 Main-is: Compiler.hs
@@ -114,4 +115,5 @@ Executable elm
114 pandoc <= 1.9.4.2,
115 pandoc <= 1.9.4.2,
115 bytestring,
116 bytestring,
116 hjsmin,
117 hjsmin,
117− indents
118+ indents,
119+ filepath
elm/src/Compiler.hs+8−8
@@ -6,6 +6,7 @@ import Data.List (intersect, intercalate)
6import Data.Maybe (fromMaybe)
6import Data.Maybe (fromMaybe)
7import Data.Version (showVersion)
7import Data.Version (showVersion)
8import System.Console.CmdArgs
8import System.Console.CmdArgs
9+import System.FilePath
9import Text.Blaze.Html.Renderer.String (renderHtml)
10import Text.Blaze.Html.Renderer.String (renderHtml)
10
11
11import qualified Text.Jasmine as JS
12import qualified Text.Jasmine as JS
@@ -17,6 +18,7 @@ import CompileToJS
17import GenerateHtml
18import GenerateHtml
18import Paths_Elm
19import Paths_Elm
19
20
21+import System.IO.Unsafe
20
22
21data ELM =
23data ELM =
22 ELM { make :: Bool
24 ELM { make :: Bool
@@ -68,12 +70,10 @@ fileTo isMini get what jsFiles noscript outputDir rtLoc file = do
68 case ems of
70 case ems of
69 Left err -> putStrLn $ "Error while compiling " ++ file ++ ":\n" ++ err
71 Left err -> putStrLn $ "Error while compiling " ++ file ++ ":\n" ++ err
70 Right ms ->
72 Right ms ->
71− let path = case outputDir of
73+ let path = fromMaybe "" outputDir </> file
72− Nothing -> reverse . tail . dropWhile (/='.') $ reverse file
73− Just dir -> (\s -> dir ++ "/" ++ s) . reverse . takeWhile (/='/') . tail . dropWhile (/='.') $ reverse file
74− js = path ++ ".js"
74+ js = replaceExtension path ".js"
75− html = path ++ ".html"
75+ html = replaceExtension path ".html"
76− in case what of
76+ in case unsafePerformIO (print path) `seq` what of
77 JS -> writeFile js . formatJS $ jss ++ concatMap jsModule ms
77 JS -> writeFile js . formatJS $ jss ++ concatMap jsModule ms
78 HTML -> writeFile html . renderHtml $ modulesToHtml jsStyle "" rtLoc jss noscript ms
78 HTML -> writeFile html . renderHtml $ modulesToHtml jsStyle "" rtLoc jss noscript ms
79 Split -> do
79 Split -> do
@@ -105,10 +105,10 @@ toFilePath :: String -> FilePath
105toFilePath modul = map (\c -> if c == '.' then '/' else c) modul ++ ".elm"
105toFilePath modul = map (\c -> if c == '.' then '/' else c) modul ++ ".elm"
106
106
107builtInModules =
107builtInModules =
108− concat [ [ "List", "Char", "Maybe", "Dict", "Set", "Automaton" ]
108+ concat [ [ "List", "Char", "Maybe", "Dict", "Set", "Automaton", "Date" ]
109 , [ "Signal", "Mouse", "Keyboard.Raw"
109 , [ "Signal", "Mouse", "Keyboard.Raw"
110 , "Window", "Time", "HTTP", "Input", "Random" ]
110 , "Window", "Time", "HTTP", "Input", "Random" ]
111 , [ "Graphics", "Text", "Color" ]
111 , [ "Graphics", "Text", "Color" ]
112− , map ("JavaScript"++) [ "", "Experimental" ]
112+ , map ("JavaScript"++) [ "", ".Experimental" ]
113 , [ "Prelude", "JSON" ]
113 , [ "Prelude", "JSON" ]
114 ]
114 ]