Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing message about "type applications should start with a type atom" #105

Closed
fredcy opened this issue Mar 30, 2016 · 5 comments
Closed

Comments

@fredcy
Copy link

fredcy commented Mar 30, 2016

I get the following error message from elm-make (0.16) when compiling the code following that.

-- TYPE MISMATCH ------------------------------------------------------ Main.elm

The type annotation for `update` does not match its definition.

17│ update : Users -> Action -> Users
             ^^^^^^^^^^^^^^^^^^^^^^^^
The type annotation is saying:

    Users -> Action -> Users

But I am inferring that the definition has this type:

    elm-make: type applications should start with a type atom
module Main (..) where

type alias Users =
  { users : List User
  }

type alias User =
  { name : String
  }

type Action
  = X (Result () List)

update : Users -> Action -> Users
update model action model =
  case action of
    X result ->
      case result of
        Ok users ->
          Users (List.map2 (+) model.users users)
@fredcy
Copy link
Author

fredcy commented Mar 30, 2016

That line with List.map2 is wrong but the error message is little help in determining that.

I have not been able to reproduce the problem with any program smaller than the above.

@jvoigtlaender
Copy link

To me, that's not an issue of a confusing message. It's a proper compiler bug. See elm/compiler#1326.

@fredcy
Copy link
Author

fredcy commented Mar 31, 2016

This case does have an error message very similar to that compiler issue. Should I close this issue and just leave it linked from that one?

@jvoigtlaender
Copy link

I think that would make sense, yes.

Additionally, I just now realized that your code is not (only?) wrong in the List.map2 line. The first line of the update definition is bad in its own way:

update model action model =

Note the two parameters with same name. So this is also relevant: elm/compiler#809.

@fredcy
Copy link
Author

fredcy commented Mar 31, 2016

For the record, it wasn't my code. I was helping someone who posted their uncompilable code as a Gist. We got that working but the original version caused the error message above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants