on master help sign in
Merge branch 'master' of https://github.com/evancz/Elm
ad56915evancz
elm/Elm.cabal+7−15
@@ -1,6 +1,6 @@
1
1
2Name: Elm
2Name: Elm
3−Version: 0.1.2.1
3+Version: 0.2
4Synopsis: The Elm language module.
4Synopsis: The Elm language module.
5Description: Elm aims to make client-side web-development more pleasant.
5Description: Elm aims to make client-side web-development more pleasant.
6 It is a statically/strongly typed, functional reactive
6 It is a statically/strongly typed, functional reactive
@@ -31,7 +31,6 @@ source-repository head
31Library
31Library
32 exposed-modules: Language.Elm,
32 exposed-modules: Language.Elm,
33 Language.Elm.Quasi
33 Language.Elm.Quasi
34− ghc-options: -O2
35 Hs-Source-Dirs: src, src/Parse, src/Types
34 Hs-Source-Dirs: src, src/Parse, src/Types
36 other-modules: Ast,
35 other-modules: Ast,
37 CompileToJS,
36 CompileToJS,
@@ -40,14 +39,11 @@ Library
40 Guid,
39 Guid,
41 Initialize,
40 Initialize,
42 Rename,
41 Rename,
43− Binop,
42+ Binops,
44− Combinators,
43+ Patterns,
45− Lexer,
46− ParsePatterns,
47 Parser,
44 Parser,
48− ParserLib,
45+ ParseLib,
49 ParseTypes,
46 ParseTypes,
50− Tokens,
51 Types,
47 Types,
52 Constrain,
48 Constrain,
53 Hints,
49 Hints,
@@ -68,7 +64,6 @@ Library
68
64
69Executable elm
65Executable elm
70 Main-is: Compiler.hs
66 Main-is: Compiler.hs
71− ghc-options: -O2
72 Hs-Source-Dirs: src, src/Parse, src/Types
67 Hs-Source-Dirs: src, src/Parse, src/Types
73 other-modules: Ast,
68 other-modules: Ast,
74 CompileToJS,
69 CompileToJS,
@@ -77,14 +72,11 @@ Executable elm
77 Guid,
72 Guid,
78 Initialize,
73 Initialize,
79 Rename,
74 Rename,
80− Binop,
75+ Binops,
81− Combinators,
76+ Patterns,
82− Lexer,
83− ParsePatterns,
84 Parser,
77 Parser,
85− ParserLib,
78+ ParseLib,
86 ParseTypes,
79 ParseTypes,
87− Tokens,
88 Types,
80 Types,
89 Constrain,
81 Constrain,
90 Hints,
82 Hints,
elm/src/CompileToJS.hs+4−1
@@ -9,9 +9,12 @@ import Data.Map (toList)
9
9
10import Initialize
10import Initialize
11
11
12+showErr :: String -> String
13+showErr err = "text(monospace(" ++ msg ++ "))"
14+ where msg = show . concatMap (++"<br>") . lines $ err
12
15
13compile = (return . addMain . toJS) <=< initialize
16compile = (return . addMain . toJS) <=< initialize
14−compileToJS = addMain . either (\err -> "text('"++err++"')") toJS
17+compileToJS = addMain . either showErr toJS
15addMain body = "function main(){return " ++ body ++ ";}"
18addMain body = "function main(){return " ++ body ++ ";}"
16
19
17parens = ("("++) . (++")")
20parens = ("("++) . (++")")
elm/src/Compiler.hs+1−1
@@ -11,7 +11,7 @@ main = getArgs >>= parse
11
11
12parse :: [String] -> IO ()
12parse :: [String] -> IO ()
13parse ("--help":_) = putStrLn usage
13parse ("--help":_) = putStrLn usage
14−parse ("--version":_) = putStrLn "The Elm Compiler 0.1.2.1"
14+parse ("--version":_) = putStrLn "The Elm Compiler 0.2"
15parse [loc,file]
15parse [loc,file]
16 | "--runtime-location=" `isPrefixOf` loc =
16 | "--runtime-location=" `isPrefixOf` loc =
17 produceHtml (tail $ dropWhile (/='=') loc) file
17 produceHtml (tail $ dropWhile (/='=') loc) file
elm/src/Initialize.hs+3−10
@@ -6,23 +6,16 @@ import Control.Monad
6import Data.Char (isAlpha)
6import Data.Char (isAlpha)
7import Data.Maybe (mapMaybe)
7import Data.Maybe (mapMaybe)
8import Data.Either (rights)
8import Data.Either (rights)
9−import Lexer
9+
10−import Parser (toExpr,toDefs)
10+import Parser (toDefs)
11import Rename (rename)
11import Rename (rename)
12
12
13import Unify
13import Unify
14import Hints
14import Hints
15
15
16−{--
17−initialize str = do
18− (expr, hints') <- toDefs =<< tokenize str
19− let expr' = rename expr
20− subs <- unify (liftM2 (++) hints hints') expr'
21− return (seq subs expr')
22−--}
23
16
24initialize str = do
17initialize str = do
25− (expr, hints') <- toDefs =<< tokenize str
18+ (expr, hints') <- toDefs str
26 let expr' = rename expr
19 let expr' = rename expr
27 subs <- unify (liftM2 (++) hints hints') expr'
20 subs <- unify (liftM2 (++) hints hints') expr'
28 let init = simp_loop expr'
21 let init = simp_loop expr'