on master help sign in
* restructuring, part #1

I am splitting the elm package up into several packages, elm itself which exports the Language.Elm* modules and builds the compiler executable, elm-server which contains the standalone, Happstack-based Elm server and elm-yesod, which provides the generateWidget function for using Elm together with Yesod.

commitf2e8703a2beec26b006f814cd31caf1652cbb92b authorVincent Ambo <v.ambo@me.com> dateMon 28 May 2012, 16:43 (14 years ago) parentf7e9852
49 files changed+174−100
Elm.cabal−73 src/GenerateHtml.hs → elm-blaze/GenerateHtml.hs elm-blaze/elm-blaze.cabal src/Server.hs → elm-server/Server.hs elm-server/elm-server.cabal+13 src/Language/Elm/Yesod.hs → elm-yesod/Yesod.hs+1−4 elm/Elm.cabal+93 LICENSE → elm/LICENSE Setup.hs → elm/Setup.hs core-js/Element.js → elm/core-js/Element.js core-js/Everything.js → elm/core-js/Everything.js core-js/Guid.js → elm/core-js/Guid.js core-js/List.js → elm/core-js/List.js core-js/String.js → elm/core-js/String.js core-js/Text.js → elm/core-js/Text.js core-js/Value.js → elm/core-js/Value.js core-js/cat-js.sh → elm/core-js/cat-js.sh core-js/collage/Color.js → elm/core-js/collage/Color.js core-js/collage/Form.js → elm/core-js/collage/Form.js core-js/collage/Image.js → elm/core-js/collage/Image.js core-js/collage/Line.js → elm/core-js/collage/Line.js core-js/collage/Shape.js → elm/core-js/collage/Shape.js core-js/runtime/Dispatcher.js → elm/core-js/runtime/Dispatcher.js core-js/runtime/Signal.js → elm/core-js/runtime/Signal.js elm-mini.js → elm/elm-mini.js src/Ast.hs → elm/src/Ast.hs src/Compiler.hs → elm/src/Compiler.hs+3−4 src/FreeVar.hs → elm/src/FreeVar.hs src/Guid.hs → elm/src/Guid.hs elm/src/Language/Elm.hs+18 src/CompileToJS.hs → elm/src/Language/Elm/CompileToJS.hs+2−2 src/ExtractNoscript.hs → elm/src/Language/Elm/ExtractNoscript.hs+1−1 elm/src/Language/Elm/GenerateHtml.hs+42 src/Initialize.hs → elm/src/Language/Elm/Initialize.hs+1−1 src/Parse/Binop.hs → elm/src/Parse/Binop.hs src/Parse/Combinators.hs → elm/src/Parse/Combinators.hs src/Parse/Lexer.hs → elm/src/Parse/Lexer.hs src/Parse/ParsePatterns.hs → elm/src/Parse/ParsePatterns.hs src/Parse/ParseTypes.hs → elm/src/Parse/ParseTypes.hs src/Parse/Parser.hs → elm/src/Parse/Parser.hs src/Parse/ParserLib.hs → elm/src/Parse/ParserLib.hs src/Parse/Tokens.hs → elm/src/Parse/Tokens.hs src/Rename.hs → elm/src/Rename.hs src/Replace.hs → elm/src/Replace.hs src/Types/Constrain.hs → elm/src/Types/Constrain.hs src/Types/Hints.hs → elm/src/Types/Hints.hs src/Types/Types.hs → elm/src/Types/Types.hs src/Types/Unify.hs → elm/src/Types/Unify.hs src/Language/Elm.hs−15
Elm.cabaldeleted−73
@@ -1,73 +0,0 @@
1−
2−Name: Elm
3−Version: 0.1.1.7
4−Synopsis: The Elm compiler and server.
5−Description: Elm aims to make client-side web-development more pleasant.
6− It is a statically/strongly typed, functional reactive
7− language to HTML, CSS, and JS. This package provides a
8− compiler and server for Elm.
9−
10−Homepage: http://elm-lang.org
11−
12−License: BSD3
13−License-file: LICENSE
14−
15−Author: Evan Czaplicki
16−Maintainer: info@elm-lang.org
17−Copyright: Copyright: (c) 2011-2012 Evan Czaplicki
18−
19−Category: Compiler, Language
20−
21−Build-type: Simple
22−
23−Extra-source-files: README.md
24−Cabal-version: >=1.6
25−
26−source-repository head
27− type: git
28− location: git://github.com/evancz/Elm.git
29−
30−Executable elm
31− -- .hs or .lhs file containing the Main module.
32− Main-is: Compiler.hs
33− Hs-Source-Dirs: src, src/Parse, src/Types, src/Language
34− other-modules: Ast, CompileToJS, GenerateHtml, Guid, Initialize,
35− Rename, Language.Elm, Binop, Combinators, Lexer,
36− ParsePatterns, Parser, ParserLib, ParseTypes, Tokens,
37− Types, Constrain, Hints, Types, Unify, ExtractNoscript
38−
39− -- Packages needed in order to build this package.
40− ghc-options: -O3
41− Build-depends: base >=4.2 && <5, containers >= 0.3,
42− transformers >= 0.2, mtl >= 2, parsec >= 3.1.1,
43− blaze-html == 0.5.0.*, blaze-markup == 0.5.1.*,
44− deepseq
45−
46− -- Modules not exported by this package.
47− -- Other-modules:
48−
49− -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.
50− -- Build-tools:
51−
52−
53−Executable elm-server
54− Main-is: Server.hs
55− Hs-Source-Dirs: src, src/Parse, src/Types
56− other-modules: Ast, CompileToJS, GenerateHtml, Guid, Initialize,
57− Rename, Language.Elm, Binop, Combinators, Lexer,
58− ParsePatterns, Parser, ParserLib, ParseTypes, Tokens,
59− Types, Constrain, Hints, Types, Unify, ExtractNoscript
60− ghc-options: -O3
61− Build-depends: base >=4.2 && <5, containers >= 0.3, transformers >= 0.2,
62− mtl >= 2, parsec >= 3.1.1, blaze-html == 0.5.0.*,
63− HTTP >= 4000, happstack-server == 7.0.2,
64− deepseq, yesod-core, shakespeare-css, shakespeare-js, hamlet,
65− template-haskell
66−
67−Library
68− exposed-modules: Language.Elm, Language.Elm.Yesod
69− Hs-Source-Dirs: src, src/Parse, src/Types
70− other-modules: Ast, CompileToJS, GenerateHtml, Guid, Initialize,
71− Rename, Binop, Combinators, Lexer,
72− ParsePatterns, Parser, ParserLib, ParseTypes, Tokens,
73− Types, Constrain, Hints, Types, Unify, ExtractNoscript
src/GenerateHtml.hs → elm-blaze/GenerateHtml.hsrenamed

The content is the same.

elm-blaze/elm-blaze.cabalnew file

No changes to the content.

src/Server.hs → elm-server/Server.hsrenamed

The content is the same.

elm-server/elm-server.cabalnew file+13
@@ -0,0 +1,13 @@
1+Executable elm-server
2+ Main-is: Server.hs
3+ Hs-Source-Dirs: src, src/Parse, src/Types
4+ other-modules: Ast, CompileToJS, GenerateHtml, Guid, Initialize,
5+ Rename, Language.Elm, Binop, Combinators, Lexer,
6+ ParsePatterns, Parser, ParserLib, ParseTypes, Tokens,
7+ Types, Constrain, Hints, Types, Unify, ExtractNoscript
8+ ghc-options: -O3
9+ Build-depends: base >=4.2 && <5, containers >= 0.3, transformers >= 0.2,
10+ mtl >= 2, parsec >= 3.1.1, blaze-html == 0.5.0.*,
11+ HTTP >= 4000, happstack-server == 7.0.2,
12+ deepseq, yesod-core, shakespeare-css, shakespeare-js, hamlet,
13+
src/Language/Elm/Yesod.hs → elm-yesod/Yesod.hsrenamed+1−4
@@ -1,6 +1,6 @@
11{-# LANGUAGE QuasiQuotes, TemplateHaskell #-}
22
3−module Language.Elm.Yesod (elm, generateWidget) where
3+module Language.Elm.Yesod (generateWidget) where
44
55import Language.Haskell.TH.Quote
66import Language.Haskell.TH
@@ -14,9 +14,6 @@ import Initialize
1414import CompileToJS
1515import ExtractNoscript
1616
17−elm :: QuasiQuoter
18−elm = QuasiQuoter {quoteExp = \s -> [|s|] }
19−
2017css = [lucius|
2118* { padding:0; margin:0;
2219hyphens: auto; -moz-hyphens: auto;
elm/Elm.cabalnew file+93
@@ -0,0 +1,93 @@
1+
2+Name: Elm
3+Version: 0.1.1.8
4+Synopsis: The Elm language module.
5+Description: Elm aims to make client-side web-development more pleasant.
6+ It is a statically/strongly typed, functional reactive
7+ language to HTML, CSS, and JS. This package provides a
8+ library for Elm compilation in Haskell and a compiler
9+ executable.
10+
11+Homepage: http://elm-lang.org
12+
13+License: BSD3
14+License-file: LICENSE
15+
16+Author: Evan Czaplicki
17+Maintainer: info@elm-lang.org
18+Copyright: Copyright: (c) 2011-2012 Evan Czaplicki
19+
20+Category: Compiler, Language
21+
22+Build-type: Simple
23+
24+Extra-source-files: README.md
25+Cabal-version: >=1.6
26+
27+source-repository head
28+ type: git
29+ location: git://github.com/evancz/Elm.git
30+
31+Executable elm
32+ -- .hs or .lhs file containing the Main module.
33+ Main-is: Compiler.hs
34+ Hs-Source-Dirs: src, src/Parse, src/Types, src/Language
35+ other-modules: Ast,
36+ Binop,
37+ Combinators,
38+ Constrain,
39+ Guid,
40+ Hints,
41+ Lexer,
42+ ParsePatterns,
43+ Parser,
44+ ParserLib,
45+ ParseTypes,
46+ Rename,
47+ Tokens,
48+ Types,
49+ Types,
50+ Unify
51+
52+ ghc-options: -O2
53+ Build-depends: base >=4.2 && <5,
54+ containers >= 0.3,
55+ transformers >= 0.2,
56+ mtl >= 2,
57+ parsec >= 3.1.1,
58+ blaze-html == 0.5.0.*,
59+ blaze-markup == 0.5.1.*,
60+ deepseq
61+
62+Library
63+ exposed-modules: Language.Elm,
64+ Language.Elm.CompileToJS,
65+ Language.Elm.ExtractNoscript,
66+ Language.Elm.Initialize
67+ Hs-Source-Dirs: src, src/Parse, src/Types
68+ other-modules: Ast,
69+ Guid,
70+ Rename,
71+ Binop,
72+ Combinators,
73+ Lexer,
74+ ParsePatterns,
75+ Parser,
76+ ParserLib,
77+ ParseTypes,
78+ Tokens,
79+ Types,
80+ Constrain,
81+ Hints,
82+ Types,
83+ Unify
84+
85+ Build-depends: base >=4.2 && <5,
86+ containers >= 0.3,
87+ transformers >= 0.2,
88+ mtl >= 2,
89+ parsec >= 3.1.1,
90+ blaze-html == 0.5.0.*,
91+ blaze-markup == 0.5.1.*,
92+ deepseq,
93+ template-haskell
LICENSE → elm/LICENSErenamed

The content is the same.

Setup.hs → elm/Setup.hsrenamed

The content is the same.

core-js/Element.js → elm/core-js/Element.jsrenamed

The content is the same.

core-js/Everything.js → elm/core-js/Everything.jsrenamed

The content is the same.

core-js/Guid.js → elm/core-js/Guid.jsrenamed

The content is the same.

core-js/List.js → elm/core-js/List.jsrenamed

The content is the same.

core-js/String.js → elm/core-js/String.jsrenamed

The content is the same.

core-js/Text.js → elm/core-js/Text.jsrenamed

The content is the same.

core-js/Value.js → elm/core-js/Value.jsrenamed

The content is the same.

core-js/cat-js.sh → elm/core-js/cat-js.shrenamed

The content is the same.

core-js/collage/Color.js → elm/core-js/collage/Color.jsrenamed

The content is the same.

core-js/collage/Form.js → elm/core-js/collage/Form.jsrenamed

The content is the same.

core-js/collage/Image.js → elm/core-js/collage/Image.jsrenamed

The content is the same.

core-js/collage/Line.js → elm/core-js/collage/Line.jsrenamed

The content is the same.

core-js/collage/Shape.js → elm/core-js/collage/Shape.jsrenamed

The content is the same.

core-js/runtime/Dispatcher.js → elm/core-js/runtime/Dispatcher.jsrenamed

The content is the same.

core-js/runtime/Signal.js → elm/core-js/runtime/Signal.jsrenamed

The content is the same.

elm-mini.js → elm/elm-mini.jsrenamed

The content is the same.

src/Ast.hs → elm/src/Ast.hsrenamed

The content is the same.

src/Compiler.hs → elm/src/Compiler.hsrenamed+3−4
@@ -1,10 +1,9 @@
1−
21module Main where
32
4−import System.Environment
5−import CompileToJS
63import Data.List (isPrefixOf)
7−import GenerateHtml
4+import Language.Elm.CompileToJS
5+import Language.Elm.GenerateHtml
6+import System.Environment
87import Text.Blaze.Html.Renderer.String (renderHtml)
98
109main = getArgs >>= parse
src/FreeVar.hs → elm/src/FreeVar.hsrenamed

The content is the same.

src/Guid.hs → elm/src/Guid.hsrenamed

The content is the same.

elm/src/Language/Elm.hsnew file+18
@@ -0,0 +1,18 @@
1+{-# LANGUAGE QuasiQuotes, TemplateHaskell #-}
2+
3+module Language.Elm (
4+ module Language.Elm.Initialize,
5+ module Language.Elm.CompileToJS,
6+ module Language.Elm.ExtractNoscript,
7+ generateHtml,
8+ elm) where
9+
10+import Language.Elm.CompileToJS
11+import Language.Elm.ExtractNoscript
12+import Language.Elm.Initialize
13+import Language.Elm.GenerateHtml
14+import Language.Haskell.TH
15+import Language.Haskell.TH.Quote
16+
17+elm :: QuasiQuoter
18+elm = QuasiQuoter {quoteExp = \s -> [|s|] }
src/CompileToJS.hs → elm/src/Language/Elm/CompileToJS.hsrenamed+2−2
@@ -1,5 +1,5 @@
11
2−module CompileToJS (compile, compileToJS) where
2+module Language.Elm.CompileToJS (compile, compileToJS) where
33
44import Ast
55import Control.Monad (liftM,(<=<),join)
@@ -7,7 +7,7 @@ import Data.Char (isAlpha)
77import Data.List (intercalate,sortBy)
88import Data.Map (toList)
99
10−import Initialize
10+import Language.Elm.Initialize
1111
1212
1313compile = (return . addMain . toJS) <=< initialize
src/ExtractNoscript.hs → elm/src/Language/Elm/ExtractNoscript.hsrenamed+1−1
@@ -1,5 +1,5 @@
11
2−module ExtractNoscript (extract) where
2+module Language.Elm.ExtractNoscript (extract) where
33
44import Ast
55
elm/src/Language/Elm/GenerateHtml.hsnew file+42
@@ -0,0 +1,42 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+module Language.Elm.GenerateHtml (generateHtml) where
3+
4+import Text.Blaze (preEscapedToMarkup)
5+import qualified Text.Blaze.Html5 as H
6+import Text.Blaze.Html5 ((!))
7+import qualified Text.Blaze.Html5.Attributes as A
8+
9+import Language.Elm.Initialize
10+import Language.Elm.CompileToJS
11+import Language.Elm.ExtractNoscript
12+
13+css = preEscapedToMarkup $
14+ ("* { padding:0; margin:0; \
15+ \hyphens: auto; -moz-hyphens: auto;\
16+ \ -webkit-hyphens: auto; -ms-hyphens: auto; }\
17+ \body { font-family: Arial; }\
18+ \a:link {text-decoration: none}\
19+ \a:visited {text-decoration: none}\
20+ \a:active {text-decoration: none}\
21+ \a:hover {text-decoration: underline; color: #ff8f12;}" :: String)
22+
23+makeScript :: String -> H.Html
24+makeScript s = H.script ! A.type_ "text/javascript" ! A.src (H.toValue s) $ ""
25+
26+generateHtml libLoc title source =
27+ let expr = initialize source
28+ js = compileToJS expr
29+ noscript = either id extract expr
30+ in
31+ H.docTypeHtml $ do
32+ H.head $ do
33+ H.meta ! A.charset "UTF-8"
34+ H.title . H.toHtml $ title
35+ makeScript libLoc
36+ H.script ! A.type_ "text/javascript" $ preEscapedToMarkup js
37+ H.style ! A.type_ "text/css" $ css
38+ H.body $ do
39+ H.div ! A.id "widthChecker" ! A.style "width:100%; height:1px; position:absolute; top:-1px;" $ ""
40+ H.span ! A.id "content" $ ""
41+ H.script ! A.type_ "text/javascript" $ "Dispatcher.initialize()"
42+ H.noscript $ preEscapedToMarkup noscript
src/Initialize.hs → elm/src/Language/Elm/Initialize.hsrenamed+1−1
@@ -1,4 +1,4 @@
1−module Initialize (initialize) where
1+module Language.Elm.Initialize (initialize) where
22
33import Ast
44import Control.Arrow (first, second)
src/Parse/Binop.hs → elm/src/Parse/Binop.hsrenamed

The content is the same.

src/Parse/Combinators.hs → elm/src/Parse/Combinators.hsrenamed

The content is the same.

src/Parse/Lexer.hs → elm/src/Parse/Lexer.hsrenamed

The content is the same.

src/Parse/ParsePatterns.hs → elm/src/Parse/ParsePatterns.hsrenamed

The content is the same.

src/Parse/ParseTypes.hs → elm/src/Parse/ParseTypes.hsrenamed

The content is the same.

src/Parse/Parser.hs → elm/src/Parse/Parser.hsrenamed

The content is the same.

src/Parse/ParserLib.hs → elm/src/Parse/ParserLib.hsrenamed

The content is the same.

src/Parse/Tokens.hs → elm/src/Parse/Tokens.hsrenamed

The content is the same.

src/Rename.hs → elm/src/Rename.hsrenamed

The content is the same.

src/Replace.hs → elm/src/Replace.hsrenamed

The content is the same.

src/Types/Constrain.hs → elm/src/Types/Constrain.hsrenamed

The content is the same.

src/Types/Hints.hs → elm/src/Types/Hints.hsrenamed

The content is the same.

src/Types/Types.hs → elm/src/Types/Types.hsrenamed

The content is the same.

src/Types/Unify.hs → elm/src/Types/Unify.hsrenamed

The content is the same.

src/Language/Elm.hsdeleted−15
@@ -1,15 +0,0 @@
1−
2−module Language.Elm where
3−
4−import GenerateHtml
5−import Text.Blaze.Html (Html)
6−
7−-- | The 'compileToHtml' function takes three string arguments: the
8−-- location of the Elm runtime (elm-mini.js), the title to be used in
9−-- the resulting HTML page, and the Elm source code. For example,
10−--
11−-- > compileToHtml "/elm-mini.js" "Hello, World!" "main = plainText \"Hello, World!\""
12−
13−compileToHtml :: String -> String -> String -> Html
14−compileToHtml libLoc fileName source =
15− generateHtml libLoc fileName source