on master help sign in
Merge branch 'master' of https://github.com/evancz/Elm
commitad569150cb4efc7c6f1ed3d8579e7df8bb864ca7 authorevancz <info@elm-lang.org> dateSat 9 Jun 2012, 23:22 (14 years ago) parent6940ddde82cf70
4 files changed+15−27
elm/Elm.cabal+7−15 elm/src/CompileToJS.hs+4−1 elm/src/Compiler.hs+1−1 elm/src/Initialize.hs+3−10
elm/Elm.cabal+7−15
@@ -1,6 +1,6 @@
11
22Name: Elm
3−Version: 0.1.2.1
3+Version: 0.2
44Synopsis: The Elm language module.
55Description: Elm aims to make client-side web-development more pleasant.
66 It is a statically/strongly typed, functional reactive
@@ -31,7 +31,6 @@ source-repository head
3131Library
3232 exposed-modules: Language.Elm,
3333 Language.Elm.Quasi
34− ghc-options: -O2
3534 Hs-Source-Dirs: src, src/Parse, src/Types
3635 other-modules: Ast,
3736 CompileToJS,
@@ -40,14 +39,11 @@ Library
4039 Guid,
4140 Initialize,
4241 Rename,
43− Binop,
44− Combinators,
45− Lexer,
46− ParsePatterns,
42+ Binops,
43+ Patterns,
4744 Parser,
48− ParserLib,
45+ ParseLib,
4946 ParseTypes,
50− Tokens,
5147 Types,
5248 Constrain,
5349 Hints,
@@ -68,7 +64,6 @@ Library
6864
6965Executable elm
7066 Main-is: Compiler.hs
71− ghc-options: -O2
7267 Hs-Source-Dirs: src, src/Parse, src/Types
7368 other-modules: Ast,
7469 CompileToJS,
@@ -77,14 +72,11 @@ Executable elm
7772 Guid,
7873 Initialize,
7974 Rename,
80− Binop,
81− Combinators,
82− Lexer,
83− ParsePatterns,
75+ Binops,
76+ Patterns,
8477 Parser,
85− ParserLib,
78+ ParseLib,
8679 ParseTypes,
87− Tokens,
8880 Types,
8981 Constrain,
9082 Hints,
elm/src/CompileToJS.hs+4−1
@@ -9,9 +9,12 @@ import Data.Map (toList)
99
1010import Initialize
1111
12+showErr :: String -> String
13+showErr err = "text(monospace(" ++ msg ++ "))"
14+ where msg = show . concatMap (++"<br>") . lines $ err
1215
1316compile = (return . addMain . toJS) <=< initialize
14−compileToJS = addMain . either (\err -> "text('"++err++"')") toJS
17+compileToJS = addMain . either showErr toJS
1518addMain body = "function main(){return " ++ body ++ ";}"
1619
1720parens = ("("++) . (++")")
elm/src/Compiler.hs+1−1
@@ -11,7 +11,7 @@ main = getArgs >>= parse
1111
1212parse :: [String] -> IO ()
1313parse ("--help":_) = putStrLn usage
14−parse ("--version":_) = putStrLn "The Elm Compiler 0.1.2.1"
14+parse ("--version":_) = putStrLn "The Elm Compiler 0.2"
1515parse [loc,file]
1616 | "--runtime-location=" `isPrefixOf` loc =
1717 produceHtml (tail $ dropWhile (/='=') loc) file
elm/src/Initialize.hs+3−10
@@ -6,23 +6,16 @@ import Control.Monad
66import Data.Char (isAlpha)
77import Data.Maybe (mapMaybe)
88import Data.Either (rights)
9−import Lexer
10−import Parser (toExpr,toDefs)
9+
10+import Parser (toDefs)
1111import Rename (rename)
1212
1313import Unify
1414import Hints
1515
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−--}
2316
2417initialize str = do
25− (expr, hints') <- toDefs =<< tokenize str
18+ (expr, hints') <- toDefs str
2619 let expr' = rename expr
2720 subs <- unify (liftM2 (++) hints hints') expr'
2821 let init = simp_loop expr'