Skip to content

Commit 184b22a

Browse files
committed
Add release notes!
1 parent 32059a2 commit 184b22a

File tree

1 file changed

+162
-0
lines changed

1 file changed

+162
-0
lines changed

upgrade-docs/0.19.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Upgrading to 0.19
2+
3+
To make the process as smooth as possible, this document outlines all the things you need to do to upgrade to 0.19.
4+
5+
- [Command Line](#command-line)
6+
- [`elm.json`](#elmjson)
7+
- [Changes](#changes)
8+
- [`--optimize`](#--optimize)
9+
- [Compiler Performance](#compiler-performance)
10+
- [Parse Errors](#parse-errors)
11+
- [Stricter Record Update Syntax](#stricter-record-update-syntax)
12+
- [Removed User-Defined Operators](#removed-user-defined-operators)
13+
14+
> **Note:** You can try out [`elm-upgrade`](https://github.com/avh4/elm-upgrade/tree/rc#elm-upgrade--) which automates some of the 0.18 to 0.19 changes. It is also in an alpha stage, and Aaron has said it makes sense to talk things through [here](https://github.com/avh4/elm-upgrade/issues).
15+
16+
<br>
17+
18+
19+
## Command Line
20+
21+
There is now just one `elm` binary at the command line. The terminal commands are now:
22+
23+
```bash
24+
# 0.19 # 0.18
25+
elm make # elm-make
26+
elm repl # elm-repl
27+
elm reactor # elm-reactor
28+
elm install # elm-package install
29+
elm publish # elm-package publish
30+
elm bump # elm-package bump
31+
elm diff # elm-package diff
32+
```
33+
34+
35+
<br>
36+
37+
38+
## `elm.json`
39+
40+
`elm-package.json` becomes `elm.json` which is specialized for applications and packages. For example, it helps you lock your dependencies in applications and get broad dependency ranges in packages.
41+
42+
See the full outlines here:
43+
44+
- `elm.json` for [applications](https://github.com/elm/compiler/blob/master/docs/elm.json/application.md)
45+
- `elm.json` for [packages](https://github.com/elm/compiler/blob/master/docs/elm.json/package.md)
46+
47+
Both are quite similar to the `elm-package.json` format, and `elm-upgrade` can help you with this.
48+
49+
<br>
50+
51+
52+
## Changes
53+
54+
#### Functions Changed
55+
56+
- `String.toInt : String -> Maybe Int` (not `Result` anymore)
57+
- `String.toFloat : String -> Maybe Float` (not `Result` anymore)
58+
- `Basics.toString` becomes [`Debug.toString`](https://alpha.elm-lang.org/packages/elm/core/latest/Debug#toString), [`String.fromInt`](https://alpha.elm-lang.org/packages/elm/core/latest/String#toInt), and [`String.fromFloat`](https://alpha.elm-lang.org/packages/elm/core/latest/String#toFloat).
59+
- `Basics.rem 451 10` becomes [`remainderBy 10 451`](https://alpha.elm-lang.org/packages/elm/core/latest/Basics#remainderBy)
60+
- `451 % 10` becomes [`modBy 10 451`](https://alpha.elm-lang.org/packages/elm/core/latest/Basics#modBy)
61+
- `style : List (String, String) -> Attribute msg` becomes `String -> String -> Attribute msg`
62+
- `Html.beginnerProgram` becomes [`Browser.sandbox`](https://alpha.elm-lang.org/packages/elm/browser/latest/Browser#sandbox).
63+
- `Html.program` becomes [`Browser.element`](https://alpha.elm-lang.org/packages/elm/browser/latest/Browser#element) and [`Browser.document`](https://alpha.elm-lang.org/packages/elm/browser/latest/Browser#document).
64+
65+
66+
#### Modules Moved
67+
68+
- `Json.Encode` and `Json.Decode` moved to [`elm/json`](https://alpha.elm-lang.org/packages/elm/json/latest)
69+
- `Time` and `Date` moved to [`elm/time`](https://alpha.elm-lang.org/packages/elm/time/latest/) with a significantly improved API
70+
- `Random` moved to [`elm/random`](https://alpha.elm-lang.org/packages/elm/random/latest/) with a better implementation and a few new functions
71+
- `Regex` moved to [`elm/regex`](https://alpha.elm-lang.org/packages/elm/regex/latest) with a much clearer README
72+
73+
74+
#### Packages Moved
75+
76+
- `elm-lang/*` moved to `elm/*`
77+
- `evancz/url-parser` moved to [`elm/url`](https://alpha.elm-lang.org/packages/elm/url/latest) with a simpler and more flexible API
78+
- `elm-tools/elm-parser` moved to [`elm/parser`](https://alpha.elm-lang.org/packages/elm/parser/latest) with speed boost when compiling with the `--optimize` flag
79+
- [`elm/browser`](https://alpha.elm-lang.org/packages/elm/browser/latest) combines and simplifies the following 0.18 packages:
80+
- `elm-lang/navigation` with smoother APIs
81+
- `elm-lang/dom` with ability to get node positions and dimensions.
82+
- `elm-lang/mouse` with decoders
83+
- `elm-lang/window`
84+
- `elm-lang/keyboard` uses decoders like [this](https://github.com/elm/browser/blob/master/notes/keyboard.md)
85+
- `elm-lang/page-visibility`
86+
- `elm-lang/animation-frame`
87+
88+
89+
#### Functions Removed
90+
91+
- `uncurry`
92+
- `curry`
93+
- `flip`
94+
95+
Prefer named helper functions in these cases.
96+
97+
<br>
98+
99+
## `--optimize`
100+
101+
You can now compile with `elm make --optimize` which enables things like:
102+
103+
- Reliable field name shortening in compiled assets
104+
- Unbox things like `type Height = Height Float` to just be a float at runtime
105+
- Unbox `Char` values
106+
- Use more compact names for `type` constructors in compiled assets.
107+
108+
Some of these optimizations require "forgetting information" that is useful while debugging, so the `Debug` module becomes unavailable when you add the `--optimize` flag. The idea being that you want to be shipping code with this flag (like `-O2` in C) but not compiling with it all day in development.
109+
110+
<br>
111+
112+
113+
## Compiler Performance
114+
115+
I did a bunch of performance optimizations for the compiler itself. For example:
116+
117+
- I rewrote the parser to be very significantly faster (partly by allocating very little!)
118+
- I revamped how type inference looks up the type of foreign variables to be `O(1)` rather than `O(log(n))`
119+
- I redid how code is generated to allow DCE with declarations as the level of granuality
120+
- Packages are downloaded once per user and saved in `~/.elm/`
121+
- Packages are built once for any given set of dependencies, so they do not contribute to build times of fresh projects.
122+
123+
Point is, the compiler is very significantly faster!
124+
125+
126+
<br>
127+
128+
129+
## Parse Errors
130+
131+
Part of rewriting the parser was making nicer parse errors. Many people only really see them when getting started, and rather than saying "man, these are terrible" they think "man, programming is hard" leading to a big underreporting of quality issues here. Anyway, please explore that a bit and see if you run into anything odd!
132+
133+
<br>
134+
135+
136+
## Stricter Record Update Syntax
137+
138+
It used to be possible for `{ r | x = v }` to change the type of field `x`. This is no longer possible. This greatly improves the quality of error messages in many cases.
139+
140+
You can still change the type of a field, but you must reconstruct the record with the record literal syntax, or with a record constructor.
141+
142+
The idea is that 99.9% of uses get a much better experience with type errors, whereas 0.1% of uses become somewhat more verbose. As someone who had a bit of code that changed record types, I have found this to be a really excellent trade.
143+
144+
<br>
145+
146+
147+
## Removed User-Defined Operators
148+
149+
It is no longer possible to define custom operators. For example, someone defined:
150+
151+
```elm
152+
(|-~->) : (a -> a1_1 -> a3) -> (a2 -> a1_1) -> a -> a2 -> a3
153+
```
154+
155+
They are still able to define that function, but it will need a human readable name that explains what it is meant to do. The reasoning behind this decision is outlined in detail in [this document](https://gist.github.com/evancz/769bba8abb9ddc3bf81d69fa80cc76b1).
156+
157+
<br>
158+
159+
160+
## Notes:
161+
162+
- `toString` &mdash; A relatively common bug was to show an `Int` in the UI, and then later that value changes to something else. `toString` would just show wrong information until someone noticed. The new `String.fromInt` and `String.fromFloat` ensure that cannot happen. Furthermore, more elaborate types almost certainly need localization or internationalization, which should be handled differently anyway.

0 commit comments

Comments
 (0)