Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Elm 0.19.0 Changes

Elm 0.19.0 Changes

An overview of Elm 0.19.0 changes with upgrade experiences stemmed from an existing app and open sourced packages.

Brooke Kuhlmann

April 17, 2024
Tweet

More Decks by Brooke Kuhlmann

Other Decks in Programming

Transcript

  1. Existing Project Lines of Code ----------------------------- --------------- ------------- ---------------- ------

    Language fi les blank comment code ----------------------------- --------------- ------------- ---------------- ------ YAML 332 26 25 58856 Ruby 932 6675 1404 32248 Elm 75 1731 320 8435 Markdown 10 856 0 2667 Sass 42 401 0 2102 ERB 26 131 118 767 Slim 11 127 7 398 HTML 3 15 3 182 JavaScript 3 23 8 73 JSON 2 0 0 48 Bourne Shell 1 4 0 18 ----------------------------- --------------- ------------- ---------------- ------ SUM: 1437 9989 1885 105794 ----------------------------- --------------- ------------- ---------------- ------ cloc.sourceforge.net alchemists.io
  2. Existing Project Lines of Code ----------------------------- --------------- ------------- ---------------- ------

    Language fi les blank comment code ----------------------------- --------------- ------------- ---------------- ------ YAML 332 26 25 58856 Ruby 932 6675 1404 32248 Elm 75 1731 320 8435 Markdown 10 856 0 2667 Sass 42 401 0 2102 ERB 26 131 118 767 Slim 11 127 7 398 HTML 3 15 3 182 JavaScript 3 23 8 73 JSON 2 0 0 48 Bourne Shell 1 4 0 18 ----------------------------- --------------- ------------- ---------------- ------ SUM: 1437 9989 1885 105794 ----------------------------- --------------- ------------- ---------------- ------ cloc.sourceforge.net cloc --exclude-dir=coverage,elm-stu ff ,log,node_modules,tmp,vendor . alchemists.io
  3. Existing Project Lines of Code ----------------------------- --------------- ------------- ---------------- ------

    Language fi les blank comment code ----------------------------- --------------- ------------- ---------------- ------ YAML 332 26 25 58856 Ruby 932 6675 1404 32248 Elm 75 1731 320 8435 Markdown 10 856 0 2667 Sass 42 401 0 2102 ERB 26 131 118 767 Slim 11 127 7 398 HTML 3 15 3 182 JavaScript 3 23 8 73 JSON 2 0 0 48 Bourne Shell 1 4 0 18 ----------------------------- --------------- ------------- ---------------- ------ SUM: 1437 9989 1885 105794 ----------------------------- --------------- ------------- ---------------- ------ cloc.sourceforge.net cloc --exclude-dir=coverage,elm-stu ff ,log,node_modules,tmp,vendor . ➡ alchemists.io
  4. Existing Project Lines of Code ----------------------------- --------------- ------------- ---------------- ------

    Language fi les blank comment code ----------------------------- --------------- ------------- ---------------- ------ YAML 332 26 25 58856 Ruby 932 6675 1404 32248 Elm 75 1731 320 8435 Markdown 10 856 0 2667 Sass 42 401 0 2102 ERB 26 131 118 767 Slim 11 127 7 398 HTML 3 15 3 182 JavaScript 3 23 8 73 JSON 2 0 0 48 Bourne Shell 1 4 0 18 ----------------------------- --------------- ------------- ---------------- ------ SUM: 1437 9989 1885 105794 ----------------------------- --------------- ------------- ---------------- ------ cloc.sourceforge.net cloc --exclude-dir=coverage,elm-stu ff ,log,node_modules,tmp,vendor . ➡ ➡ alchemists.io
  5. Existing Project Lines of Code ----------------------------- --------------- ------------- ---------------- ------

    Language fi les blank comment code ----------------------------- --------------- ------------- ---------------- ------ YAML 332 26 25 58856 Ruby 932 6675 1404 32248 Elm 75 1731 320 8435 Markdown 10 856 0 2667 Sass 42 401 0 2102 ERB 26 131 118 767 Slim 11 127 7 398 HTML 3 15 3 182 JavaScript 3 23 8 73 JSON 2 0 0 48 Bourne Shell 1 4 0 18 ----------------------------- --------------- ------------- ---------------- ------ SUM: 1437 9989 1885 105794 ----------------------------- --------------- ------------- ---------------- ------ cloc.sourceforge.net cloc --exclude-dir=coverage,elm-stu ff ,log,node_modules,tmp,vendor . ➡ ➡ Client alchemists.io
  6. Existing Project Lines of Code ----------------------------- --------------- ------------- ---------------- ------

    Language fi les blank comment code ----------------------------- --------------- ------------- ---------------- ------ YAML 332 26 25 58856 Ruby 932 6675 1404 32248 Elm 75 1731 320 8435 Markdown 10 856 0 2667 Sass 42 401 0 2102 ERB 26 131 118 767 Slim 11 127 7 398 HTML 3 15 3 182 JavaScript 3 23 8 73 JSON 2 0 0 48 Bourne Shell 1 4 0 18 ----------------------------- --------------- ------------- ---------------- ------ SUM: 1437 9989 1885 105794 ----------------------------- --------------- ------------- ---------------- ------ cloc.sourceforge.net cloc --exclude-dir=coverage,elm-stu ff ,log,node_modules,tmp,vendor . ➡ ➡ API Client alchemists.io
  7. Existing Project Success! Compiled 152 modules. ✨ Done in 45.57s.

    Full Compile Partial Compile alchemists.io
  8. Existing Project Success! Compiled 152 modules. ✨ Done in 45.57s.

    Full Compile Success! Compiled 3 modules. ✨ Done in 11.21s. Partial Compile alchemists.io
  9. Upgrading (new commands) elm repl --help elm init --help elm

    reactor --help elm make --help elm install --help elm bump --help elm di ff --help elm publish --help elm-test Run: elm alchemists.io
  10. Upgrading (new commands) elm repl --help elm init --help elm

    reactor --help elm make --help elm install --help elm bump --help elm di ff --help elm publish --help elm-test Run: elm One binary to rule them all alchemists.io
  11. Upgrading (new commands) elm repl --help elm init --help elm

    reactor --help elm make --help elm install --help elm bump --help elm di ff --help elm publish --help elm-test Run: elm ➡ One binary to rule them all alchemists.io
  12. Upgrading (Tests) ├── src │ ├── FormValidator │ │ ├──

    Models.elm │ │ ├── Patterns.elm │ │ ├── Validator.elm │ │ ├── Validators.elm │ │ └── Views.elm │ └── FormValidator.elm ├── tests │ ├── FormValidator │ │ ├── PatternsTest.elm │ │ ├── ValidatorTest.elm │ │ └── ValidatorsTest.elm │ └── Main.elm alchemists.io
  13. Upgrading (Tests) ├── src │ ├── FormValidator │ │ ├──

    Models.elm │ │ ├── Patterns.elm │ │ ├── Validator.elm │ │ ├── Validators.elm │ │ └── Views.elm │ └── FormValidator.elm ├── tests │ ├── FormValidator │ │ ├── PatternsTest.elm │ │ ├── ValidatorTest.elm │ │ └── ValidatorsTest.elm │ └── Main.elm alchemists.io
  14. Upgrading (Tests) ├── src │ ├── FormValidator │ │ ├──

    Models.elm │ │ ├── Patterns.elm │ │ ├── Validator.elm │ │ ├── Validators.elm │ │ └── Views.elm │ └── FormValidator.elm ├── tests │ ├── FormValidator │ │ ├── PatternsTest.elm │ │ ├── ValidatorTest.elm │ │ └── ValidatorsTest.elm │ └── Main.elm 🎉 🎉 alchemists.io
  15. Upgrading (elm.json) "dependencies": { "direct": { "elm/browser": "1.0.0", "elm/core": "1.0.0",

    "elm/html": "1.0.0" }, "indirect": { "elm/regex": "1.0.0", "elm/virtual-dom": "1.0.0" } } Direct versus Indirect alchemists.io
  16. Upgrading (elm.json) "dependencies": { "direct": { "elm/browser": "1.0.0", "elm/core": "1.0.0",

    "elm/html": "1.0.0" }, "indirect": { "elm/regex": "1.0.0", "elm/virtual-dom": "1.0.0" } } ➡ Direct versus Indirect alchemists.io
  17. Upgrading (elm.json) "dependencies": { "direct": { "elm/browser": "1.0.0", "elm/core": "1.0.0",

    "elm/html": "1.0.0" }, "indirect": { "elm/regex": "1.0.0", "elm/virtual-dom": "1.0.0" } } ➡ Direct versus Indirect alchemists.io
  18. Upgrading (elm.json) elm install "elm/regex" I found it in your

    elm.json fi le, but in the "indirect" dependencies. Should I move it into "direct" dependencies for more general use? [Y/n]: alchemists.io
  19. Upgrading (elm.json) "dependencies": { "direct": { "elm/browser": "1.0.0", "elm/core": "1.0.0",

    "elm/html": "1.0.0", "elm/regex": "1.0.0" }, "indirect": { "elm/virtual-dom": "1.0.0" } } alchemists.io
  20. Upgrading (elm.json) "dependencies": { "direct": { "elm/browser": "1.0.0", "elm/core": "1.0.0",

    "elm/html": "1.0.0", "elm/regex": "1.0.0" }, "indirect": { "elm/virtual-dom": "1.0.0" } } ➡ alchemists.io
  21. Upgrading (package.json) "scripts": { "build": "elm make src/FormValidator.elm --warn --output=tmp/form-validator.js",

    "live": "elm live src/FormValidator.elm --warn --debug --output=tmp/form-validator.js" } Elm 0.18 alchemists.io
  22. Upgrading (package.json) "scripts": { "build": "elm make src/FormValidator.elm --warn --output=tmp/form-validator.js",

    "live": "elm live src/FormValidator.elm --warn --debug --output=tmp/form-validator.js" } "scripts": { "build": "elm make src/FormValidator.elm --optimize --output=tmp/form-validator.js", "live": "elm live src/FormValidator.elm --optimize --debug --output=tmp/form-validator.js" }, Elm 0.18 Elm 0.19 alchemists.io
  23. Upgrading (package.json) "scripts": { "build": "elm make src/FormValidator.elm --warn --output=tmp/form-validator.js",

    "live": "elm live src/FormValidator.elm --warn --debug --output=tmp/form-validator.js" } "scripts": { "build": "elm make src/FormValidator.elm --optimize --output=tmp/form-validator.js", "live": "elm live src/FormValidator.elm --optimize --debug --output=tmp/form-validator.js" }, Elm 0.18 Elm 0.19 🚫 🚫 alchemists.io
  24. Upgrading (package.json) "scripts": { "build": "elm make src/FormValidator.elm --warn --output=tmp/form-validator.js",

    "live": "elm live src/FormValidator.elm --warn --debug --output=tmp/form-validator.js" } "scripts": { "build": "elm make src/FormValidator.elm --optimize --output=tmp/form-validator.js", "live": "elm live src/FormValidator.elm --optimize --debug --output=tmp/form-validator.js" }, Elm 0.18 Elm 0.19 🚫 🚫 ✅ alchemists.io
  25. viewLabel : Maybe String -> Html message viewLabel label =

    case label of Just label -> label Nothing -> "Unknown" elm-lang.org/0.19.0/shadowing Syntax (Variable Shadowing) alchemists.io
  26. viewLabel : Maybe String -> Html message viewLabel label =

    case label of Just label -> label Nothing -> "Unknown" elm-lang.org/0.19.0/shadowing Shadow variable! Syntax (Variable Shadowing) alchemists.io
  27. viewLabel : Maybe String -> Html message viewLabel label =

    case label of Just label -> label Nothing -> "Unknown" 🚫 elm-lang.org/0.19.0/shadowing Shadow variable! Syntax (Variable Shadowing) alchemists.io
  28. viewLabel : Maybe String -> Html message viewLabel label =

    case label of Just label -> label Nothing -> "Unknown" 🚫 elm-lang.org/0.19.0/shadowing viewLabel : Maybe String -> Html message viewLabel aLabel = case aLabel of Just label -> label Nothing -> "Unknown" Shadow variable! Syntax (Variable Shadowing) alchemists.io
  29. viewLabel : Maybe String -> Html message viewLabel label =

    case label of Just label -> label Nothing -> "Unknown" 🚫 elm-lang.org/0.19.0/shadowing viewLabel : Maybe String -> Html message viewLabel aLabel = case aLabel of Just label -> label Nothing -> "Unknown" Shadow variable! Fixed Syntax (Variable Shadowing) alchemists.io
  30. viewLabel : Maybe String -> Html message viewLabel label =

    case label of Just label -> label Nothing -> "Unknown" 🚫 ✅ elm-lang.org/0.19.0/shadowing viewLabel : Maybe String -> Html message viewLabel aLabel = case aLabel of Just label -> label Nothing -> "Unknown" Shadow variable! Fixed Syntax (Variable Shadowing) alchemists.io
  31. Syntax (Tuples) (1, 2) ✅ (1, 2, 3) ✅ (1,

    2, 3, 4) 🚫 alchemists.io
  32. Syntax (Tuples) (1, 2) ✅ (1, 2, 3) ✅ (1,

    2, 3, 4) 🚫 I recommend switching to records. Each item will be named, and you can use the `point.x` syntax to access them. alchemists.io
  33. Syntax (Time) import Time import Json.Encode as JSONE raw =

    1535235380000 elm install elm/time alchemists.io
  34. Syntax (Time) import Time import Json.Encode as JSONE raw =

    1535235380000 time = Time.millisToPosix raw elm install elm/time alchemists.io
  35. Syntax (Time) import Time import Json.Encode as JSONE raw =

    1535235380000 time = Time.millisToPosix raw value = JSONE.int <| Time.posixToMillis time elm install elm/time alchemists.io
  36. Syntax (Regular Expressions) import Regex Regex.regex "^\\s*$" elm install elm/regex

    Regex.fromString "^\\s*$" |> Maybe.withDefault Regex.never 🚫 alchemists.io
  37. Syntax (Regular Expressions) import Regex Regex.regex "^\\s*$" elm install elm/regex

    Regex.fromString "^\\s*$" |> Maybe.withDefault Regex.never ✅ 🚫 alchemists.io
  38. Syntax (Programs) package.elm-lang.org/packages/elm/browser/latest/Browser#application main : Program Never Model Message main

    = Html.program { init = init, view = view, update = update, subscriptions = subscriptions } alchemists.io
  39. Syntax (Programs) main : Program Flags Model Message main =

    Browser.application { init = init, view = view, update = update, subscriptions = subscriptions, onUrlRequest = ClickedLink, onUrlChange = ChangedUrl } package.elm-lang.org/packages/elm/browser/latest/Browser#application main : Program Never Model Message main = Html.program { init = init, view = view, update = update, subscriptions = subscriptions } alchemists.io