on master help sign in
Merge branch 'master' of https://github.com/evancz/Elm
68840c6evancz
Examples/elm-yesod/Main.hs+2−2
@@ -17,7 +17,7 @@ clockPage = $(elmFile "elm_source/clock.elm")
17shapesPage = [elm|
17shapesPage = [elm|
18square = rect 200 200 (150,150)
18square = rect 200 200 (150,150)
19circle = oval 140 140 (150,150)
19circle = oval 140 140 (150,150)
20−pentagon = ngon 5 60 (150,150) --@
20+pentagon = ngon 5 60 (150,150)
21
21
22main = collage 300 300
22main = collage 300 300
23 [ outlined black square
23 [ outlined black square
@@ -75,7 +75,7 @@ instance Yesod ElmTest where
75 hamletToRepHtml $(hamletFile "templates/default-layout-wrapper.hamlet")
75 hamletToRepHtml $(hamletFile "templates/default-layout-wrapper.hamlet")
76
76
77instance YesodElm ElmTest where
77instance YesodElm ElmTest where
78− urlElmJs _ = Right $ "http://f.cl.ly/items/2e3Z3r3v29263U393c3x/elm-min.js"
78+ urlElmJs _ = Right $ "https://raw.github.com/evancz/Elm/master/elm/elm-runtime-0.3.0.js"
79
79
80main :: IO ()
80main :: IO ()
81main = warpDebug 3000 ElmTest
81main = warpDebug 3000 ElmTest
Examples/elm-yesod/elm_source/clock.elm+5−4
@@ -1,12 +1,13 @@
1−clockColor = rgb (6/16) (11/16) (14/16)
1+
2+import Signal.Time (every)
2
3
3hand clr len time =
4hand clr len time =
4− let t = Math.PI * time / 30 - Math.PI / 2 in
5+ let t = pi * time / 30 - pi / 2 in
5 solid clr $ line [(200,200), (200 + len * cos t, 200 + len * sin t)]
6 solid clr $ line [(200,200), (200 + len * cos t, 200 + len * sin t)]
6
7
7−clock t = collage 400 400 [ filled clockColor $ ngon 12 110 (200, 200)
8+clock t = collage 400 400 [ filled (rgb 96 176 224) $ ngon 12 110 (200, 200)
8 , hand red 100 t
9 , hand red 100 t
9 , hand black 100 (t/60)
10 , hand black 100 (t/60)
10 , hand black 60 (t/720) ]
11 , hand black 60 (t/720) ]
11
12
12−main = lift clock $ Time.every 1
13+main = lift clock (every 1)
Examples/elm-yesod/elm_source/index.elm+2−2
@@ -1,7 +1,7 @@
1title w = size w 60 . box 4 . text . header . toText $ "Elm-Yesod"
1title w = size w 60 . box 4 . text . header . toText $ "Elm-Yesod"
2
2
3−lightGrey = rgb (240/255) (241/255) (244/255)
3+lightGrey = rgb 240 241 244
4−mediumGrey = rgb (216/255) (221/255) (225/255)
4+mediumGrey = rgb 216 221 225
5heading outer inner =
5heading outer inner =
6 color mediumGrey . size outer 61 . box 1 .
6 color mediumGrey . size outer 61 . box 1 .
7 color lightGrey . size outer 60 . box 5 .
7 color lightGrey . size outer 60 . box 5 .
Examples/elm-yesod/elm_source/mouse.elm+11−5
@@ -1,9 +1,15 @@
1−niceBlue = rgb 0 (1/3) (2/3)
1+
2−clearGreen = rgba (1/9) (8/9) (3/9) (1/2)
2+-- Move your mouse around above the canvas!
3+
4+import Signal.Mouse (position)
5+import Signal.Window (dimensions)
6+
7+myBlue = rgb 0 85 170
8+myGreen = rgba 28 267 85 (1/2)
3
9
4scene (x,y) (w,h) =
10scene (x,y) (w,h) =
5− collage w h [ filled niceBlue . rotate ((x+y)/1000) $ ngon 4 100 (200,200)
11+ collage w h [ filled myBlue . rotate ((x+y)/1000) $ ngon 4 100 (200,200)
6− , filled clearGreen $ ngon 5 30 (x,y)
12+ , filled myGreen $ ngon 5 30 (x,y)
7 ]
13 ]
8
14
9−main = lift2 scene Mouse.position Window.dimensions
15+main = lift2 scene position dimensions
README.md+5−4
@@ -19,21 +19,22 @@ This will ensure that the elm package is available. Then install Elm with:
19
19
20Assuming everything goes correctly (potential problems are discussed later), this will build two executables on your machine:
20Assuming everything goes correctly (potential problems are discussed later), this will build two executables on your machine:
21
21
22−* `elm` is a standard compiler that takes `.elm` files and produces `.html` files. You can then use these HTML files with your favorite web-framework.
22+* `elm` is a standard compiler that takes `.elm` files and produces `.html` and/or `.js` files. You can then use these files with your favorite web-framework.
23
23
24* `elm-server` is both a compiler and server, allowing you to develop without designing and setting up a server yourself. Running `elm-server` starts a server in the current directory. It will compile and serve any `.elm` files in the current directory and its sub-directories. This is how I prefer to develop Elm programs.
24* `elm-server` is both a compiler and server, allowing you to develop without designing and setting up a server yourself. Running `elm-server` starts a server in the current directory. It will compile and serve any `.elm` files in the current directory and its sub-directories. This is how I prefer to develop Elm programs.
25
25
26−To use these executables you need to add a new directory to your PATH. For me, the executables were placed in /home/evan/.cabal/bin which I appended to the end of my PATH variable in my .bashrc file. Cabal should tell you where your executables are located, so you can make a similar addition (see this tutorial if you are new to changing your PATH in [Unix/Linux](http://www.cyberciti.biz/faq/unix-linux-adding-path/)).
26+To use these executables you need to add a new directory to your PATH. For me, the executables were placed in `/home/evan/.cabal/bin` which I appended to the end of my PATH variable in my .bashrc file. Cabal should tell you where your executables are located upon successful installation, so you can make a similar addition (see this tutorial if you are new to changing your PATH in [Unix/Linux](http://www.cyberciti.biz/faq/unix-linux-adding-path/)).
27
27
28That is almost everything. Now, we will create a simple Elm project. The following commands will set-up a very basic project and start the Elm server.
28That is almost everything. Now, we will create a simple Elm project. The following commands will set-up a very basic project and start the Elm server.
29
29
30 mkdir helloElm
30 mkdir helloElm
31 cd helloElm
31 cd helloElm
32− wget https://raw.github.com/evancz/Elm/master/elm-mini.js
33 echo main = lift asText Mouse.position > main.elm
32 echo main = lift asText Mouse.position > main.elm
34 elm-server
33 elm-server
35
34
36−The first two commands create a new directory and navigate into it. Then next command (`wget`) downloads the [elm-mini.js](https://raw.github.com/evancz/Elm/master/elm-mini.js) file which is the Elm runtime system and must be in the root directory of your Elm project. If you do not have wget, just follow [this link](https://raw.github.com/evancz/Elm/master/elm-mini.js) and download it directly. The `echo` command places a simple program into `main.elm` (do this manually if you do not have `echo`). The final command starts the Elm server at [localhost](http://localhost:8000/), allowing you to navigate to `main.elm` and see your first program in action.
35+The first two commands create a new directory and navigate into it. The `echo` command places a simple program into `main.elm` (do this manually if you do not have `echo`). The final command starts the Elm server at [localhost](http://localhost:8000/), allowing you to navigate to `main.elm` and see your first program in action.
36+
37+An important note: When you install the `elm` compiler, it automatically downloads Elm's JavaScript runtime system and places it in the same place as the `elm` executable (`/home/evan/.cabal/bin` or wherever it happens to be on your system). The runtime system will follow the name scheme `elm-runtime-x.y.z.js` where `x.y.z` matches the version number of the compiler. If you want to serve this file from a different location, *copy* it from its home and always be sure that code compiled with version `x.y.z` of the compiler is served with version `x.y.z` of the runtime system.
37
38
38
39
39Installation for Haskell-users
40Installation for Haskell-users