on master help sign in
Clean-up after dependency changes. Replace foldl with foldl' in some places.
commitae6984c33103e2ff872beff2acc3377158cc82a1 authorevancz <info@elm-lang.org> dateSun 20 May 2012, 01:14 (14 years ago) parentb571124
6 files changed+29−37
src/Elm.hs+1−1 src/GenerateHtml.hs+21−20 src/Parse/Binop.hs+1−1 src/Parse/Combinators.hs+3−3 src/Server.hs+2−6 src/ToHtml.hs+1−6
src/Elm.hs+1−1
@@ -5,7 +5,7 @@ import System.Environment
55import CompileToJS
66import Data.List (isPrefixOf)
77import GenerateHtml
8−import Text.Blaze.Renderer.String
8+import Text.Blaze.Html.Renderer.String (renderHtml)
99
1010main = getArgs >>= parse
1111
src/GenerateHtml.hs+21−20
@@ -1,32 +1,33 @@
11{-# LANGUAGE OverloadedStrings #-}
22module GenerateHtml (generateHtml) where
33
4−import Text.Blaze.Html5 hiding (map)
4+import Text.Blaze (preEscapedToMarkup)
55import qualified Text.Blaze.Html5 as H
6−import Text.Blaze.Html5.Attributes
6+import Text.Blaze.Html5 ((!))
77import qualified Text.Blaze.Html5.Attributes as A
88
9−css = preEscapedString "* { padding:0; margin:0; \
10− \hyphens: auto; -moz-hyphens: auto;\
11− \ -webkit-hyphens: auto; -ms-hyphens: auto; }\
12− \body { font-family: Arial; }\
13− \a:link {text-decoration: none}\
14− \a:visited {text-decoration: none}\
15− \a:active {text-decoration: none}\
16− \a:hover {text-decoration: underline; color: #ff8f12;}"
17−
18−makeScript :: String -> Html
19−makeScript s = script ! type_ "text/javascript" ! src (toValue s) $ ""
9+css = preEscapedToMarkup $
10+ ("* { padding:0; margin:0; \
11+ \hyphens: auto; -moz-hyphens: auto;\
12+ \ -webkit-hyphens: auto; -ms-hyphens: auto; }\
13+ \body { font-family: Arial; }\
14+ \a:link {text-decoration: none}\
15+ \a:visited {text-decoration: none}\
16+ \a:active {text-decoration: none}\
17+ \a:hover {text-decoration: underline; color: #ff8f12;}" :: String)
18+
19+makeScript :: String -> H.Html
20+makeScript s = H.script ! A.type_ "text/javascript" ! A.src (H.toValue s) $ ""
2021
2122generateHtml libLoc title source =
22− docTypeHtml $ do
23+ H.docTypeHtml $ do
2324 H.head $ do
24− meta ! charset "UTF-8"
25− H.title . toHtml $ title
25+ H.meta ! A.charset "UTF-8"
26+ H.title . H.toHtml $ title
2627 makeScript libLoc
27− (script ! type_ "text/javascript") . preEscapedString $ source
28− H.style ! type_ "text/css" $ css
29− body $ do
28+ (H.script ! A.type_ "text/javascript") . preEscapedToMarkup $ source
29+ H.style ! A.type_ "text/css" $ css
30+ H.body $ do
3031 H.div ! A.id "widthChecker" ! A.style "width:100%; height:1px; position:absolute; top:-1px;" $ ""
3132 H.span ! A.id "content" $ ""
32− script ! type_ "text/javascript" $ "Dispatcher.initialize()"
33+ H.script ! A.type_ "text/javascript" $ "Dispatcher.initialize()"
src/Parse/Binop.hs+1−1
@@ -39,7 +39,7 @@ binopSplit seen opTable i ops es =
3939
4040binopOf _ _ _ [e] = return e
4141binopOf _ [] ops es =
42− return $ foldl (flip ($)) (head es) $ zipWith Binop ops (tail es)
42+ return $ foldl' (flip ($)) (head es) $ zipWith Binop ops (tail es)
4343
4444binopOf seen (tbl@((lvl, L, op):rest)) ops es =
4545 case elemIndices op ops of
src/Parse/Combinators.hs+3−3
@@ -1,7 +1,7 @@
11module Combinators where
22import Control.Monad
33import Data.Char
4−import Data.List (sortBy)
4+import Data.List (sortBy,foldl',foldl1')
55
66newtype Parser from to = Parser ([from] -> [(to,[from])])
77--newtype Parser a = Parser (String -> [(a,String)])
@@ -52,7 +52,7 @@ newline = do
5252 return ""
5353
5454digit = do {x <- sat isDigit; return (ord x - ord '0')}
55−integer = do {i <- plus digit; return $ foldl (\a d -> 10 * a + d) 0 i}
55+integer = do {i <- plus digit; return $ foldl' (\a d -> 10 * a + d) 0 i}
5656
5757variable = do
5858 shd <- sat isLower;
@@ -66,7 +66,7 @@ sepBy1 sep p = do
6666 xs <- star (sep >> p)
6767 return $ x:xs
6868
69−select = foldl1 (+|+)
69+select = foldl1' (+|+)
7070
7171chainl p op a = chainl1 p op +++ return a
7272chainl1 p op = do {a <- p; rest a}
src/Server.hs+2−6
@@ -1,16 +1,12 @@
1−{-# LANGUAGE OverloadedStrings #-}
1+
22module Main where
33
4−import Prelude hiding (head,span,id)
54import Control.Monad (msum,guard)
65import Control.Monad.Trans (MonadIO(liftIO))
76import Data.List (isPrefixOf, isSuffixOf)
8−import Happstack.Server hiding (body)
7+import Happstack.Server
98import Happstack.Server.Compression
109import System.Environment
11−import Text.Blaze.Html5 hiding (map)
12−import Text.Blaze.Html5.Attributes hiding (title,span,dir,style)
13−import Text.Blaze.Internal
1410import ToHtml
1511
1612serve :: String -> IO ()
src/ToHtml.hs+1−6
@@ -2,18 +2,13 @@
22module ToHtml (compileToHtml) where
33
44import CompileToJS
5−import Data.Monoid (mempty)
65import GenerateHtml
7−import Network.HTTP.Base (urlEncode)
8−import Text.Blaze.Html5 hiding (map)
96import qualified Text.Blaze.Html5 as H
10−import Text.Blaze.Html5.Attributes
117import qualified Text.Blaze.Html5.Attributes as A
128
139pageTitle fp =
1410 reverse . takeWhile (/='/') . drop 1 . dropWhile (/='.') $ reverse fp
1511
16−
17−compileToHtml :: String -> String -> String -> Html
12+compileToHtml :: String -> String -> String -> H.Html
1813compileToHtml libLoc fileName source =
1914 generateHtml libLoc (pageTitle fileName) (compileToJS source)