elm / error-message-catalog

A catalog of broken Elm programs / data to improve error messages
BSD 3-Clause "New" or "Revised" License
173 stars 17 forks source link

Expecting T but it is T #226

Open drathier opened 7 years ago

drathier commented 7 years ago

I was missing an uncurry and got this error message:

The 3rd argument to function foldl is causing a mismatch.
Function foldl is expecting the 3rd argument to be:

List ( number, Box )

But it is:

List ( number, Box )

Hint: Only ints, floats, chars, strings, lists, and tuples are comparable.

Hint: I always figure out the type of arguments from left to right. If an
argument is acceptable when I check it, I assume it is "correct" in subsequent
checks. So the problem may actually be in how previous arguments interact with
the 3rd.

from this code

module Main exposing (..)

type alias Box =
  { position : T }

type T = T

insertNodeData : comparable -> data -> List data -> List data
insertNodeData key data lst =
    data :: lst

ok = List.foldl (uncurry insertNodeData) [] [ ( 1, Box <| T ), ( 2, Box <| T ) ]
error = List.foldl insertNodeData [] [ ( 1, Box <| T ), ( 2, Box <| T ) ]

https://ellie-app.com/3J7KXRG8QZja1/0