on master help sign in
Merge pull request #10 from tazjin/master

* splitting up elm and elm-server, adding elm-yesod

commitdce3842884df4865e83bcb8ebacb9af842bc09c0 authorEvan Czaplicki <info@elm-lang.org> dateMon 28 May 2012, 14:30 (14 years ago) parent096ff99aafc77e
41 files changed+431−102
.gitignore+2−1 Elm.cabal−72 Examples/elm-yesod/Main.hs+49 Examples/elm-yesod/client_session_key.aes+1 Examples/elm-yesod/elm_source/mouse.elm+9 Examples/elm-yesod/templates/default-layout-wrapper.hamlet+8 Examples/elm-yesod/templates/default-layout.hamlet+3 LICENSE → elm-server/LICENSE src/Server.hs → elm-server/Server.hs+2−2 elm-mini.js → elm-server/elm-mini.js elm-server/elm-server.cabal+38 elm-yesod/LICENSE+30 elm-yesod/Language/Elm/Yesod.hs+56 elm-yesod/elm-yesod.cabal+35 elm/Elm.cabal+94 elm/LICENSE+30 Setup.hs → elm/Setup.hs 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+53 src/CompileToJS.hs → elm/src/Language/Elm/CompileToJS.hs+2−2 src/ExtractNoscript.hs → elm/src/Language/Elm/ExtractNoscript.hs+1−1 src/GenerateHtml.hs → elm/src/Language/Elm/GenerateHtml.hs+14−4 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
.gitignore+2−1
@@ -3,4 +3,5 @@ cabal-dev
33*.o
44*.hi
55*.chi
6−*.chs.h
6+*.chs.h
7+.DS_Store
Elm.cabaldeleted−72
@@ -1,72 +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
65−
66−Library
67− exposed-modules: Language.Elm
68− Hs-Source-Dirs: src, src/Parse, src/Types
69− other-modules: Ast, CompileToJS, GenerateHtml, Guid, Initialize,
70− Rename, Binop, Combinators, Lexer,
71− ParsePatterns, Parser, ParserLib, ParseTypes, Tokens,
72− Types, Constrain, Hints, Types, Unify, ExtractNoscript
Examples/elm-yesod/Main.hsnew file+49
@@ -0,0 +1,49 @@
1+{-# LANGUAGE QuasiQuotes, TemplateHaskell, OverloadedStrings, TypeFamilies, MultiParamTypeClasses #-}
2+
3+import Data.Text (Text)
4+import Language.Elm
5+import Language.Elm.Yesod
6+import Yesod
7+import Yesod.Default.Util
8+import Text.Hamlet
9+import Text.Julius
10+
11+data ElmTest = ElmTest
12+
13+-- embedding an external elm file (note: no spaces!)
14+mousePage = [elmFile|elm_source/mouse.elm|]
15+
16+-- embedding elm code in our Haskell file
17+rootPage = [elm|
18+main = plainText "Welcome!"
19+|]
20+
21+-- our Yesod App
22+mkYesod "ElmTest" [parseRoutes|
23+/ RootR GET
24+/mouse MouseR GET
25+|]
26+
27+-- generateWidget is called with the result of an Elm QuasiQuoter (which is just a
28+-- string containing some Elm code, with proper newline escaping)
29+getMouseR :: Handler RepHtml
30+getMouseR = defaultLayout $ do
31+ setTitle "Mouse position demo"
32+ generateWidget mousePage
33+
34+getRootR :: Handler RepHtml
35+getRootR = defaultLayout $ do
36+ setTitle "Welcome!"
37+ generateWidget rootPage
38+
39+instance Yesod ElmTest where
40+ jsLoader _ = BottomOfHeadBlocking
41+ defaultLayout widget = do
42+ mmsg <- getMessage
43+ pc <- widgetToPageContent $ do
44+ addScriptRemote $ "http://f.cl.ly/items/2e3Z3r3v29263U393c3x/elm-min.js"
45+ $(whamletFile "templates/default-layout.hamlet")
46+ hamletToRepHtml $(hamletFile "templates/default-layout-wrapper.hamlet")
47+
48+main :: IO ()
49+main = warpDebug 3000 ElmTest
Examples/elm-yesod/client_session_key.aesnew file+1
@@ -0,0 +1 @@
1+GDfV��U.ec �XgA�.:�f���a+F�|�x�*���y��ǃ2�r?��/�e���,_�>ǣ<��a #IƎ��8�93�b?�>/1���O{�߿b�z�
Examples/elm-yesod/elm_source/mouse.elmnew file+9
@@ -0,0 +1,9 @@
1+niceBlue = rgb 0 (1/3) (2/3)
2+clearGreen = rgba (1/9) (8/9) (3/9) (1/2)
3+
4+scene (x,y) (w,h) =
5+ collage w h [ filled niceBlue . rotate ((x+y)/1000) $ ngon 4 100 (200,200)
6+ , filled clearGreen $ ngon 5 30 (x,y)
7+ ]
8+
9+main = lift2 scene Mouse.position Window.dimensions
Examples/elm-yesod/templates/default-layout-wrapper.hamletnew file+8
@@ -0,0 +1,8 @@
1+$doctype 5
2+<html>
3+ <head>
4+ <meta charset="UTF-8">
5+ <title>#{pageTitle pc}
6+ ^{pageHead pc}
7+ <body>
8+ ^{pageBody pc}
Examples/elm-yesod/templates/default-layout.hamletnew file+3
@@ -0,0 +1,3 @@
1+$maybe msg <- mmsg
2+ <div .message>#{msg}
3+^{widget}
LICENSE → elm-server/LICENSErenamed

The content is the same.

src/Server.hs → elm-server/Server.hsrenamed+2−2
@@ -11,7 +11,7 @@ import Language.Elm
1111
1212serve :: String -> IO ()
1313serve libLoc = do
14− putStrLn "Elm Server 0.1.1.7: running at <http://localhost:8000>"
14+ putStrLn "Elm Server 0.1.1.8: running at <http://localhost:8000>"
1515 simpleHTTP nullConf $ do
1616 compressedResponseFilter
1717 msum [ uriRest (serveElm libLoc)
@@ -25,7 +25,7 @@ serveElm libLoc fp = do
2525 let ('/':path) = fp
2626 guard (".elm" `isSuffixOf` path)
2727 content <- liftIO (readFile path)
28− ok . toResponse $ compileToHtml libLoc (pageTitle path) content
28+ ok . toResponse $ generateHtml libLoc (pageTitle path) content
2929
3030
3131main = getArgs >>= parse
elm-mini.js → elm-server/elm-mini.jsrenamed

The content is the same.

elm-server/elm-server.cabalnew file+38
@@ -0,0 +1,38 @@
1+Name: Elm-server
2+Version: 0.1.1.8
3+Synopsis: The Elm language server.
4+Description: This package provides a standalone, Happstack-based Elm server.
5+
6+Homepage: http://elm-lang.org
7+
8+License: BSD3
9+License-file: LICENSE
10+
11+Author: Evan Czaplicki
12+Maintainer: info@elm-lang.org
13+Copyright: Copyright: (c) 2011-2012 Evan Czaplicki
14+
15+Category: Compiler, Language
16+
17+Build-type: Simple
18+
19+Extra-source-files: README.md
20+Cabal-version: >=1.6
21+
22+source-repository head
23+ type: git
24+ location: git://github.com/evancz/Elm.git
25+
26+Executable elm-server
27+ Main-is: Server.hs
28+ ghc-options: -O2
29+ Build-depends: base >=4.2 && <5,
30+ containers >= 0.3,
31+ transformers >= 0.2,
32+ mtl >= 2,
33+ parsec >= 3.1.1,
34+ blaze-html == 0.5.0.*,
35+ HTTP >= 4000,
36+ happstack-server == 7.0.2,
37+ deepseq,
38+ Elm >= 0.1.1.8
elm-yesod/LICENSEnew file+30
@@ -0,0 +1,30 @@
1+Copyright (c)2012, Evan Czaplicki
2+
3+All rights reserved.
4+
5+Redistribution and use in source and binary forms, with or without
6+modification, are permitted provided that the following conditions are met:
7+
8+ * Redistributions of source code must retain the above copyright
9+ notice, this list of conditions and the following disclaimer.
10+
11+ * Redistributions in binary form must reproduce the above
12+ copyright notice, this list of conditions and the following
13+ disclaimer in the documentation and/or other materials provided
14+ with the distribution.
15+
16+ * Neither the name of Evan Czaplicki nor the names of other
17+ contributors may be used to endorse or promote products derived
18+ from this software without specific prior written permission.
19+
20+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
elm-yesod/Language/Elm/Yesod.hsnew file+56
@@ -0,0 +1,56 @@
1+{-# LANGUAGE QuasiQuotes #-}
2+{- | This module provides a function for compiling Elm source code into a Yesod widget.
3+ In order to use this with your Yesod app, you need to define a defaultLayout like
4+ function that embeds the elm-min.js file /in the <head> tag/.
5+
6+ For example, you could modify your Yesod instance as follows:
7+
8+ > instance Yesod App where
9+ > jsLoader _ = BottomOfHeadBlocking -- moves JS to the <head> tag
10+ > defaultLayout widget = do
11+ > pc <- widgetToPageContent $ do
12+ > addScriptRemote $ "http://somecdn.org/link/to/elm-min.js"
13+ > ...
14+ > ...
15+
16+ A full example implementation is provided in the examples folder of the Elm github repository.
17+-}
18+module Language.Elm.Yesod (generateWidget) where
19+
20+import Text.Blaze (preEscapedToMarkup)
21+import Text.Hamlet
22+import Text.Julius
23+import Text.Lucius
24+import Yesod.Widget
25+
26+import Language.Elm.Initialize
27+import Language.Elm.CompileToJS
28+import Language.Elm.ExtractNoscript
29+
30+css = [lucius|
31+* { padding:0; margin:0;
32+hyphens: auto; -moz-hyphens: auto;
33+-webkit-hyphens: auto; -ms-hyphens: auto;}
34+body { font-family: Arial; }
35+a:link, a:visited, a:active { text-decoration: none}
36+a:hover {text-decoration: underline; color: #ff8f12;}
37+|]
38+
39+-- |generateWidget takes some Elm code in String format and produces a widget. Usage example:
40+--
41+-- > generateWidget [elmFile|elm-source/somePage.elm|]
42+generateWidget :: String -- ^ The Elm source code
43+ -> GWidget sub master ()
44+generateWidget source =
45+ let expr = initialize source
46+ js = compileToJS expr
47+ noscript = either id extract expr
48+ in do toWidgetHead css
49+ toWidgetHead [julius| #{js} |]
50+ [whamlet|
51+<div #widthChecker style="width:100%; height:1px; position:absolute; top:-1px;">
52+<span #content>
53+<script type="text/javascript">
54+ Dispatcher.initialize()
55+<noscript>^{preEscapedToMarkup noscript}
56+|]
elm-yesod/elm-yesod.cabalnew file+35
@@ -0,0 +1,35 @@
1+Name: Elm-yesod
2+Version: 0.1.1.8
3+Synopsis: The Elm language Yesod compatibility module.
4+Description: This module provides a simple function to embed Elm code
5+ as a Yesod widget.
6+
7+Homepage: http://elm-lang.org
8+
9+License: BSD3
10+License-file: LICENSE
11+
12+Author: Evan Czaplicki
13+Maintainer: info@elm-lang.org
14+Copyright: Copyright: (c) 2011-2012 Evan Czaplicki
15+
16+Category: Compiler, Language
17+
18+Build-type: Simple
19+
20+Extra-source-files: README.md
21+Cabal-version: >=1.6
22+
23+source-repository head
24+ type: git
25+ location: git://github.com/evancz/Elm.git
26+
27+Library
28+ exposed-modules: Language.Elm.Yesod
29+ Build-depends: base >=4.2 && <5,
30+ blaze-markup == 0.5.*,
31+ Elm >= 0.1.1.8,
32+ yesod-core >= 1,
33+ hamlet,
34+ shakespeare-css,
35+ shakespeare-js
elm/Elm.cabalnew file+94
@@ -0,0 +1,94 @@
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+ Language.Elm.GenerateHtml
68+ Hs-Source-Dirs: src, src/Parse, src/Types
69+ other-modules: Ast,
70+ Guid,
71+ Rename,
72+ Binop,
73+ Combinators,
74+ Lexer,
75+ ParsePatterns,
76+ Parser,
77+ ParserLib,
78+ ParseTypes,
79+ Tokens,
80+ Types,
81+ Constrain,
82+ Hints,
83+ Types,
84+ Unify
85+
86+ Build-depends: base >=4.2 && <5,
87+ containers >= 0.3,
88+ transformers >= 0.2,
89+ mtl >= 2,
90+ parsec >= 3.1.1,
91+ blaze-html == 0.5.0.*,
92+ blaze-markup == 0.5.1.*,
93+ deepseq,
94+ template-haskell
elm/LICENSEnew file+30
@@ -0,0 +1,30 @@
1+Copyright (c)2012, Evan Czaplicki
2+
3+All rights reserved.
4+
5+Redistribution and use in source and binary forms, with or without
6+modification, are permitted provided that the following conditions are met:
7+
8+ * Redistributions of source code must retain the above copyright
9+ notice, this list of conditions and the following disclaimer.
10+
11+ * Redistributions in binary form must reproduce the above
12+ copyright notice, this list of conditions and the following
13+ disclaimer in the documentation and/or other materials provided
14+ with the distribution.
15+
16+ * Neither the name of Evan Czaplicki nor the names of other
17+ contributors may be used to endorse or promote products derived
18+ from this software without specific prior written permission.
19+
20+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Setup.hs → elm/Setup.hsrenamed

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+53
@@ -0,0 +1,53 @@
1+{-# LANGUAGE QuasiQuotes, TemplateHaskell #-}
2+{- | This module re-exports the modules necessary for compiling Elm code into the
3+ respective HTML, JS and CSS code.
4+
5+ It also provides a predefined generateHtml function for use with the Blaze markup library
6+ as well as a simple QuasiQuoter for embedding literal elm code in a Haskell file.
7+
8+ The documentation for the Elm language is available at <http://elm-lang.org/Documentation.elm>
9+-}
10+module Language.Elm (
11+ module Language.Elm.Initialize,
12+ module Language.Elm.CompileToJS,
13+ module Language.Elm.ExtractNoscript,
14+ generateHtml,
15+ elm,
16+ elmFile) where
17+
18+import Language.Elm.CompileToJS
19+import Language.Elm.ExtractNoscript
20+import Language.Elm.Initialize
21+import Language.Elm.GenerateHtml
22+import Language.Haskell.TH
23+import Language.Haskell.TH.Quote
24+
25+{- | This QuasiQuoter allows for literal embedding of elm source code within
26+ Haskell files. It is not responsible for the actual compilation Process.
27+ Usage:
28+
29+ @
30+ elmPage = [elm|
31+ main = image \"someImage.jpg\"
32+ |]
33+ @
34+
35+ How the elm code is compiled depends on how you intend to use it.
36+ Example uses are the included 'generateHtml' function as well as the
37+ "Language.Elm.Yesod" module.
38+-}
39+elm :: QuasiQuoter
40+elm = QuasiQuoter {quoteExp = \s -> [|s|] }
41+
42+{- | elmFile is a quoteFile wrapper around the 'elm' QuasiQuoter and allows for
43+ external elm source files to be embedded.
44+ Usage:
45+
46+ @
47+ [elmFile|elm-source/page.elm|]
48+ @
49+
50+ Please note that no spaces should be added before and after the filename.
51+-}
52+elmFile :: QuasiQuoter
53+elmFile = quoteFile elm
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
src/GenerateHtml.hs → elm/src/Language/Elm/GenerateHtml.hsrenamed+14−4
@@ -1,14 +1,15 @@
11{-# LANGUAGE OverloadedStrings #-}
2−module GenerateHtml (generateHtml) where
2+module Language.Elm.GenerateHtml (generateHtml) where
33
44import Text.Blaze (preEscapedToMarkup)
5+import Text.Blaze.Html (Html)
56import qualified Text.Blaze.Html5 as H
67import Text.Blaze.Html5 ((!))
78import qualified Text.Blaze.Html5.Attributes as A
89
9−import Initialize
10−import CompileToJS
11−import ExtractNoscript
10+import Language.Elm.Initialize
11+import Language.Elm.CompileToJS
12+import Language.Elm.ExtractNoscript
1213
1314css = preEscapedToMarkup $
1415 ("* { padding:0; margin:0; \
@@ -23,6 +24,15 @@ css = preEscapedToMarkup $
2324makeScript :: String -> H.Html
2425makeScript s = H.script ! A.type_ "text/javascript" ! A.src (H.toValue s) $ ""
2526
27+-- |This function compiles Elm code into simple HTML.
28+--
29+-- Usage example:
30+--
31+-- > generateHtml "/elm-min.js" "Some title" [elmFile|elm-source/somePage.elm|]
32+generateHtml :: String -- ^ Location of elm-min.js as expected by the browser
33+ -> String -- ^ The page title
34+ -> String -- ^ The elm source code.
35+ -> Html
2636generateHtml libLoc title source =
2737 let expr = initialize source
2838 js = compileToJS expr
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