on master help sign in
Add `Build.hs` which constructs the elm-runtime.

Found bugs in some files which are temporarily fixed: Weird type error in Either, name collision in LineStyle and syntax error in Json.Experimental

commit95679501d2b2d2b79cd4123d4d6d2b04c6bb87f0 authorevancz <info@elm-lang.org> dateSun 10 Mar 2013, 22:42 (14 years ago) parent10f0a24
4 files changed+51−14
Build.hs+37 libraries/Either.elm+9−9 libraries/Graphics/LineStyle.elm+4−4 libraries/Json/Experimental.elm+1−1
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 @@
11
22module Either where
33
4−import List (filter, partition)
4+import List
55
66data Either a b = Left a | Right b
77
@@ -9,18 +9,18 @@ either : (a -> c) -> (b -> c) -> Either a b -> c
99either f g e = case e of { Left x -> f x ; Right y -> g y }
1010
1111
12−isLeft : Either a b -> Bool
13−isLeft e = case e of { Left _ -> True ; _ -> False }
12+isLeft : Either a b -> Bool
13+isLeft e = case e of { Left _ -> True ; _ -> False }
1414
1515isRight : Either a b -> Bool
1616isRight e = case e of { Right _ -> True ; _ -> False }
1717
1818
19−lefts : [Either a b] -> [a]
20−lefts = filter isLeft
19+--lefts : [Either a b] -> [a]
20+lefts es = List.filter isLeft es
2121
22−rights : [Either a b] -> [b]
23−rights = filter isRight
22+--rights : [Either a b] -> [b]
23+rights es = List.filter isRight es
2424
25−partition : [Either a b] -> ([a],[b])
26−partition = partition isLeft
25+--partition : [Either a b] -> ([a],[b])
26+partition es = List.partition isLeft es
libraries/Graphics/LineStyle.elm+4−4
@@ -4,7 +4,7 @@ module Graphics.LineStyle where
44import Graphics.Color
55
66data LineCap = Butt | Round | Square
7−data LineJoin = Round | Bevel | Miter
7+data LineJoin = Soft | Sharp | Clip
88
99type LineStyle = {
1010 color : Color,
@@ -26,6 +26,6 @@ default = {
2626 miterLimit = 10
2727 }
2828
29−solid clr = { default | color <- clr }
30−dashed clr = { default | color <- clr, dashing = [8,4] }
31−dotted clr = { default | color <- clr, dashing = [3,3] }
29+solid clr = { default | color <- clr }
30+dashed clr = { default | color <- clr, dashing <- [8,4] }
31+dotted clr = { default | color <- clr, dashing <- [3,3] }
libraries/Json/Experimental.elm+1−1
@@ -2,7 +2,7 @@
22module Json.Experimental where
33
44import JavaScript as JS
5−import Native.Json (recordFromJSString, recordToPrettyJSString
5+import Native.Json (recordFromJSString, recordToPrettyJSString)
66
77fromString s = recordFromJSString (JS.fromString s)
88fromJSString = recordFromJSString