on master help sign in
Add `Build.hs` which constructs the elm-runtime.
9567950evancz
Build.hsnew file+37
@@ -0,0 +1,37 @@
1+-- This file compiles all Elm code then concatenates all JS code
2+-- into elm-runtime.js. Use the following command to run it:
3+--
4+-- runHaskell Build.hs
5+--
6+
7+import System.Cmd
8+import System.Directory
9+import System.FilePath
10+import System.IO
11+import Language.Elm
12+
13+getFiles ext dir = do
14+ contents <- map (dir </>) `fmap` getDirectoryContents dir
15+ let files = filter (\f -> takeExtension f == ext) contents
16+ dirs = filter (not . hasExtension) contents
17+ filess <- mapM (getFiles ext) dirs
18+ return (files ++ concat filess)
19+
20+appendJS file = do
21+ putStrLn (dropExtension file)
22+ str <- readFile file
23+ length str `seq` return ()
24+ appendFile "elm-runtime.js" str
25+
26+appendElm file = do
27+ system ("elm --only-js " ++ file)
28+ let jsFile = replaceExtension file ".js"
29+ appendJS jsFile
30+ removeFile jsFile
31+
32+main = do
33+ writeFile "elm-runtime.js" "Elm = {}; Elm.Native = {};\n"
34+ mapM_ appendJS =<< getFiles ".js" "libraries"
35+ mapM_ appendElm =<< getFiles ".elm" "libraries"
36+ mapM_ appendJS =<< getFiles ".js" "runtime"
37+
libraries/Either.elm+9−9
@@ -1,7 +1,7 @@
1
1
2module Either where
2module Either where
3
3
4−import List (filter, partition)
4+import List
5
5
6data Either a b = Left a | Right b
6data Either a b = Left a | Right b
7
7
@@ -9,18 +9,18 @@ either : (a -> c) -> (b -> c) -> Either a b -> c
9either f g e = case e of { Left x -> f x ; Right y -> g y }
9either f g e = case e of { Left x -> f x ; Right y -> g y }
10
10
11
11
12−isLeft : Either a b -> Bool
12+isLeft : Either a b -> Bool
13−isLeft e = case e of { Left _ -> True ; _ -> False }
13+isLeft e = case e of { Left _ -> True ; _ -> False }
14
14
15isRight : Either a b -> Bool
15isRight : Either a b -> Bool
16isRight e = case e of { Right _ -> True ; _ -> False }
16isRight e = case e of { Right _ -> True ; _ -> False }
17
17
18
18
19−lefts : [Either a b] -> [a]
19+--lefts : [Either a b] -> [a]
20−lefts = filter isLeft
20+lefts es = List.filter isLeft es
21
21
22−rights : [Either a b] -> [b]
22+--rights : [Either a b] -> [b]
23−rights = filter isRight
23+rights es = List.filter isRight es
24
24
25−partition : [Either a b] -> ([a],[b])
25+--partition : [Either a b] -> ([a],[b])
26−partition = partition isLeft
26+partition es = List.partition isLeft es
libraries/Graphics/LineStyle.elm+4−4
@@ -4,7 +4,7 @@ module Graphics.LineStyle where
4import Graphics.Color
4import Graphics.Color
5
5
6data LineCap = Butt | Round | Square
6data LineCap = Butt | Round | Square
7−data LineJoin = Round | Bevel | Miter
7+data LineJoin = Soft | Sharp | Clip
8
8
9type LineStyle = {
9type LineStyle = {
10 color : Color,
10 color : Color,
@@ -26,6 +26,6 @@ default = {
26 miterLimit = 10
26 miterLimit = 10
27 }
27 }
28
28
29−solid clr = { default | color <- clr }
29+solid clr = { default | color <- clr }
30−dashed clr = { default | color <- clr, dashing = [8,4] }
30+dashed clr = { default | color <- clr, dashing <- [8,4] }
31−dotted clr = { default | color <- clr, dashing = [3,3] }
31+dotted clr = { default | color <- clr, dashing <- [3,3] }
libraries/Json/Experimental.elm+1−1
@@ -2,7 +2,7 @@
2module Json.Experimental where
2module Json.Experimental where
3
3
4import JavaScript as JS
4import JavaScript as JS
5−import Native.Json (recordFromJSString, recordToPrettyJSString
5+import Native.Json (recordFromJSString, recordToPrettyJSString)
6
6
7fromString s = recordFromJSString (JS.fromString s)
7fromString s = recordFromJSString (JS.fromString s)
8fromJSString = recordFromJSString
8fromJSString = recordFromJSString