Skip to content

Instantly share code, notes, and snippets.

@evancz
Last active April 2, 2024 20:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evancz/4589b798ac2475d52b1d00cd04ace2c8 to your computer and use it in GitHub Desktop.
Save evancz/4589b798ac2475d52b1d00cd04ace2c8 to your computer and use it in GitHub Desktop.

The real announcement of Elm 0.18 was getting a bit too long, so this page splits out some concrete examples that highlight the error message improvements.


Bad Recursion

x = x + 1

bad recursion

And the link at the end, points to this comprehensive explanation of what is going wrong. This is probably the most important bug fix in this release. As you can see in the meta issue, many people were tripped up by this!


Type Annotations

type Msg = Increment | Decrement

type alias Model = { count : Int }

update : Msg -> Model -> Model
update msg model =
  case msg of
    Increment ->
      { model | count = model.count + 1 }

    Decrement ->
      { model | count = model.countt - 1 }

update annotation

This comes directly from issue #148 in the error message catalog. It was already best practice to add type annotations, but now there is a very concrete reward for doing it! More examples in the meta issue about this.


Missing Arguments

import String

fooBlah =
  "foo" ++ String.join "blah"

missing arguments

This comes directly from issue #137 in the error message catalog.


Record Precision

bad subscription

record precision

This comes directly from issue #131 in the error message catalog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment