@@ -0,0 +1,275 @@
4+Upgrading should be pretty easy. Everything is quite mechanical, so I would not be very afraid of this process.
7+## Update elm-package.json
9+Some core packages have been renamed:
11+ - `evancz/elm-html` is now `elm-lang/html`
12+ - `evancz/elm-svg` is now `elm-lang/svg`
13+ - `evancz/virtual-dom` is now `elm-lang/virtual-dom`
14+ - The functionality of `evancz/start-app` now lives in `elm-lang/html` in `Html.App`
15+ - The functionality of `evancz/elm-effects` now lives in `elm-lang/core` in `Platform.*`
16+ - The functionality of `Graphics.*` now lives in `evancz/elm-graphics`
18+So the first thing you want to do is update your `elm-package.json` file. Here is one that has been properly updated:
23+ "summary": "let people do a cool thing in a fun way",
24+ "repository": "https://github.com/user/project.git",
26+ "source-directories": [
29+ "exposed-modules": [],
31+ "elm-lang/core": "4.0.0 <= v < 5.0.0",
32+ "elm-lang/html": "1.0.0 <= v < 2.0.0",
33+ "evancz/elm-http": "3.0.1 <= v < 4.0.0",
34+ "evancz/elm-markdown": "3.0.0 <= v < 4.0.0"
36+ "elm-version": "0.17.0 <= v < 0.18.0"
40+The only changes should be in the `dependencies` and `elm-version` fields where you need to update constraints. The easiest way to get this all set up is to update `elm-version` by hand, and then remove everything from `dependencies` so you can install the dependencies you still need one at a time with `elm package install`.
45+The major syntax changes are:
56+ <td>module declaration</td>
57+ <td><pre lang="elm">module Queue (..) where</pre></td>
58+ <td><pre lang="elm">module Queue exposing (..)</pre></td>
62+This is a super easy change, so we will add a link to an auto-upgrade tool here when one exists.
65+## `Action` is now `Msg`
67+The Elm Architecture tutorial uses the term `Action` for the data that gets fed into your `update` function. This is a silly name. So in 0.17 the standard name is *message*.
71+type Action = Increment | Decrement
74+type Msg = Increment | Decrement
77+The idea is that your app is receiving *messages* from the user, from servers, from the browser, etc. Your app then reacts to these messages in the `update` function.
80+## No More `Signal.Address`
82+The most common thing in your code will probably be that `Signal.Address` no longer exists. Here is a before and after of upgrading some typical `view` code.
86+view : Signal.Address Action -> Model -> Html
89+ [ button [ onClick address Decrement ] [ text "-" ]
90+ , div [ countStyle ] [ text (toString model) ]
91+ , button [ onClick address Increment ] [ text "+" ]
95+view : Model -> Html Msg
98+ [ button [ onClick Decrement ] [ text "-" ]
99+ , div [ countStyle ] [ text (toString model) ]
100+ , button [ onClick Increment ] [ text "+" ]
104+This change is pretty simple. Any occurance of `address` just gets deleted. In the types, you see the addresses removed, and `Html` becomes `Html Msg`. You can read `Html Msg` as "an HTML node that can produce messages of type `Msg`". This change makes addresses unnecessary and makes it much clearer what kind of messages can be produced by a particular block of HTML.
106+The `Signal.forwardTo` function is replaced by `Html.App.map`. So you may need to make changes like this:
110+view : Signal.Address Action -> Model -> Html
113+ [ Counter.view (Signal.forwardTo address Top) model.topCounter
114+ , Counter.view (Signal.forwardTo address Bottom) model.bottomCounter
115+ , button [ onClick address Reset ] [ text "RESET" ]
119+view : Model -> Html Msg
122+ [ map Top (Counter.view model.topCounter)
123+ , map Bottom (Counter.view model.bottomCounter)
124+ , button [ onClick Reset ] [ text "RESET" ]
128+These changes are nice for a couple really good reasons:
130+ - Addresses were consistently one of the things that new folks found most confusing.
131+ - It allows the `elm-lang/virtual-dom` implementation to be more efficient with `lazy`
132+ - It uses a normal `map` instead of some unfamiliar API.
134+You can see more examples of the new HTML API [here](https://evancz.gitbooks.io/an-introduction-to-elm/content/architecture/user_input/index.html).
137+## `Effects` is now `Cmd`
139+If you are working with HTTP or anything, you are probably using `evancz/elm-effects` and have your `update` function returning `Effects` values. That library was a successful experiment, so it has been folded into `elm-lang/core` and given a name that works better in the context of Elm 0.17.
141+The changes are basically a simple rename:
145+update : Action -> Model -> (Model, Effects Action)
146+update action model =
149+ (model, getRandomGif model.topic)
152+ ( Model model.topic (Maybe.withDefault model.gifUrl maybeUrl)
157+update : Msg -> Model -> (Model, Cmd Msg)
161+ ( model, getRandomGif model.topic )
164+ ( Model model.topic (Maybe.withDefault model.gifUrl maybeUrl)
169+The `Cmd` stuff lives in `elm-lang/core` in `Platform.Cmd`. It is imported by default with `import Platform.Cmd as Cmd exposing (Cmd)` to make it easier to use.
171+Again, very easy changes. The key goal of 0.17 was to manage effects in a nicer way, so in making these facilities more complete, the term `Effects` became very ambiguous. You should read more about this in the updated Elm Architecture Tutorial which has [a section all about effects](https://evancz.gitbooks.io/an-introduction-to-elm/content/architecture/effects/index.html).
174+## `StartApp` is now `Html.App`
176+The `evancz/start-app` package was an experiment to help people get productive with Elm more quickly. It meant that newcomers could get really far with Elm without knowing a ton about signals, and it has been very effective. With 0.17, it has been folded in to `elm-lang/html` in the `Html.App` module.
178+Upgrading looks like this:
181+-- 0.16 ---------------------------------------
187+ { init = init, update = update, view = view, inputs = [] }
192+port tasks : Signal (Task.Task Never ())
196+-- 0.17 ---------------------------------------
197+import Html.App as Html
201+ { init = init, update = update, view = view, subscriptions = \_ -> Sub.none }
204+The type of `main` has changed from `Signal Html` to `Program flags`. The main value is a program that knows exactly how it needs to be set up. All that will be handled by Elm, so you no longer need to specially hook tasks up to a port or anything.
209+Talking to JavaScript still uses ports. It is pretty similar, but adapted to fit nicely with commands and subscriptions.
211+Here is the change for *outgoing* ports:
215+port focus : Signal String
220+port focus : String -> Cmd msg
223+Instead of hooking up a signal, you have a function that can create commands. So you just call `focus : String -> Cmd msg` from anywhere in your app and the command is processed like all the others.
225+And here is the change for *incoming* ports:
228+type User = { name : String, age : Int }
231+port users : Signal User
234+port users : (User -> msg) -> Sub msg
237+Instead of getting a signal to route to the right place, we now can create subscriptions to incoming ports. So wherever you need to know about users, you just subscribe to it.
239+You should definitely read more about this [here](https://evancz.gitbooks.io/an-introduction-to-elm/content/interop/javascript.html).
242+## JavaScript Interop
244+The style of initializing Elm programs in JS has also changed slightly.
255+ <td><pre lang="javascript">Elm.embed(Elm.Main, someNode);</pre></td>
256+ <td><pre lang="javascript">Elm.Main.embed(someNode);</pre></td>
261+ <td><pre lang="javascript">Elm.fullscreen(Elm.Main);</pre></td>
262+ <td><pre lang="javascript">Elm.Main.fullscreen();</pre></td>
267+ <td><pre lang="javascript">Elm.worker(Elm.Main);</pre></td>
268+ <td><pre lang="javascript">Elm.Main.worker();</pre></td>
275+From here, I would highly recommend looking through [guide.elm-lang.org](http://guide.elm-lang.org/), particularly the sections on [The Elm Architecture](http://guide.elm-lang.org/architecture/index.html). This will help you get a feel for 0.17.