on master help sign in
Get rid of warnings and update the version numbers in Compiler.hs and Server.hs. Get .cabal up to date for both packages.
2267cd2evancz
elm-server/Server.hs+12−7
@@ -11,27 +11,30 @@ import qualified Language.Elm as Elm
11
11
12serve :: String -> IO ()
12serve :: String -> IO ()
13serve libLoc = do
13serve libLoc = do
14− putStrLn "Elm Server 0.1.1.8: running at <http://localhost:8000>"
14+ putStrLn "Elm Server 0.1.2: running at <http://localhost:8000>"
15 simpleHTTP nullConf $ do
15 simpleHTTP nullConf $ do
16− compressedResponseFilter
16+ _ <- compressedResponseFilter
17 msum [ uriRest (serveElm libLoc)
17 msum [ uriRest (serveElm libLoc)
18 , serveDirectory EnableBrowsing [] "."
18 , serveDirectory EnableBrowsing [] "."
19 ]
19 ]
20
20
21+pageTitle :: String -> String
21pageTitle fp =
22pageTitle fp =
22 reverse . takeWhile (/='/') . drop 1 . dropWhile (/='.') $ reverse fp
23 reverse . takeWhile (/='/') . drop 1 . dropWhile (/='.') $ reverse fp
23
24
24serveElm libLoc fp = do
25serveElm libLoc fp = do
25− let ('/':path) = fp
26+ let ('/':filePath) = fp
26− guard (".elm" `isSuffixOf` path)
27+ guard (".elm" `isSuffixOf` filePath)
27− content <- liftIO (readFile path)
28+ content <- liftIO (readFile filePath)
28− ok . toResponse $ Elm.toHtml libLoc (pageTitle path) content
29+ ok . toResponse $ Elm.toHtml libLoc (pageTitle filePath) content
29
30
30
31
32+main :: IO ()
31main = getArgs >>= parse
33main = getArgs >>= parse
32
34
35+parse :: [String] -> IO ()
33parse ("--help":_) = putStrLn usage
36parse ("--help":_) = putStrLn usage
34−parse ("--version":_) = putStrLn "The Elm Server 0.1.1.7"
37+parse ("--version":_) = putStrLn "The Elm Server 0.1.2"
35parse [] = serve "/elm-mini.js"
38parse [] = serve "/elm-mini.js"
36parse [arg]
39parse [arg]
37 | "--runtime-location=" `isPrefixOf` arg =
40 | "--runtime-location=" `isPrefixOf` arg =
@@ -39,10 +42,12 @@ parse [arg]
39 | otherwise = putStrLn usageMini
42 | otherwise = putStrLn usageMini
40parse _ = putStrLn usageMini
43parse _ = putStrLn usageMini
41
44
45+usageMini :: String
42usageMini =
46usageMini =
43 "Usage: elm-server [OPTIONS]\n\
47 "Usage: elm-server [OPTIONS]\n\
44 \Try `elm-server --help' for more information."
48 \Try `elm-server --help' for more information."
45
49
50+usage :: String
46usage =
51usage =
47 "Usage: elm-server [OPTIONS]\n\
52 "Usage: elm-server [OPTIONS]\n\
48 \Compiles and serves .elm files from the current directory.\n\
53 \Compiles and serves .elm files from the current directory.\n\
elm-server/Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
elm-server/elm-server.cabal+4−4
@@ -1,4 +1,4 @@
1−Name: Elm-server
1+Name: elm-server
2Version: 0.1.2
2Version: 0.1.2
3Synopsis: The Elm language server.
3Synopsis: The Elm language server.
4Description: This package provides a standalone, Happstack-based Elm server.
4Description: This package provides a standalone, Happstack-based Elm server.
@@ -16,7 +16,7 @@ Category: Compiler, Language
16
16
17Build-type: Simple
17Build-type: Simple
18
18
19−Extra-source-files: README.md
19+--Extra-source-files: README.md
20Cabal-version: >=1.6
20Cabal-version: >=1.6
21
21
22source-repository head
22source-repository head
@@ -25,7 +25,7 @@ source-repository head
25
25
26Executable elm-server
26Executable elm-server
27 Main-is: Server.hs
27 Main-is: Server.hs
28− ghc-options: -O2
28+ ghc-options: -Wall
29 Build-depends: base >=4.2 && <5,
29 Build-depends: base >=4.2 && <5,
30 containers >= 0.3,
30 containers >= 0.3,
31 transformers >= 0.2,
31 transformers >= 0.2,
@@ -35,4 +35,4 @@ Executable elm-server
35 HTTP >= 4000,
35 HTTP >= 4000,
36 happstack-server == 7.0.2,
36 happstack-server == 7.0.2,
37 deepseq,
37 deepseq,
38− Elm >= 0.1.2
38+ Elm == 0.1.2.*
elm/Elm.cabal+1−1
@@ -21,7 +21,7 @@ Category: Compiler, Language
21
21
22Build-type: Simple
22Build-type: Simple
23
23
24−Extra-source-files: README.md
24+--Extra-source-files: README.md
25Cabal-version: >=1.8
25Cabal-version: >=1.8
26
26
27source-repository head
27source-repository head
elm/src/Compiler.hs+6−1
@@ -6,10 +6,12 @@ import GenerateHtml
6import System.Environment
6import System.Environment
7import Text.Blaze.Html.Renderer.String (renderHtml)
7import Text.Blaze.Html.Renderer.String (renderHtml)
8
8
9+main :: IO ()
9main = getArgs >>= parse
10main = getArgs >>= parse
10
11
12+parse :: [String] -> IO ()
11parse ("--help":_) = putStrLn usage
13parse ("--help":_) = putStrLn usage
12−parse ("--version":_) = putStrLn "The Elm Compiler 0.1.1.7"
14+parse ("--version":_) = putStrLn "The Elm Compiler 0.1.2"
13parse [loc,file]
15parse [loc,file]
14 | "--runtime-location=" `isPrefixOf` loc =
16 | "--runtime-location=" `isPrefixOf` loc =
15 produceHtml (tail $ dropWhile (/='=') loc) file
17 produceHtml (tail $ dropWhile (/='=') loc) file
@@ -17,6 +19,7 @@ parse [loc,file]
17parse [file] = produceHtml "elm-mini.js" file
19parse [file] = produceHtml "elm-mini.js" file
18parse _ = putStrLn usageMini
20parse _ = putStrLn usageMini
19
21
22+produceHtml :: String -> FilePath -> IO ()
20produceHtml libLoc file = do
23produceHtml libLoc file = do
21 code <- readFile file
24 code <- readFile file
22 let name = takeWhile (/='.') file
25 let name = takeWhile (/='.') file
@@ -25,10 +28,12 @@ produceHtml libLoc file = do
25 Right jsCode -> writeFile (name ++ ".html") . renderHtml $
28 Right jsCode -> writeFile (name ++ ".html") . renderHtml $
26 generateHtml libLoc name jsCode
29 generateHtml libLoc name jsCode
27
30
31+usageMini :: String
28usageMini =
32usageMini =
29 "Usage: elm [OPTIONS] FILE\n\
33 "Usage: elm [OPTIONS] FILE\n\
30 \Try `elm --help' for more information."
34 \Try `elm --help' for more information."
31
35
36+usage :: String
32usage =
37usage =
33 "Usage: elm [OPTIONS] FILE\n\
38 "Usage: elm [OPTIONS] FILE\n\
34 \Compile .elm files to .html files.\n\
39 \Compile .elm files to .html files.\n\