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

Errors about "expected (something), got Maybe a" could use hints #181

Open Zacqary opened 7 years ago

Zacqary commented 7 years ago

I ran into an issue when I was trying to write an update of Int -> Array.Array number > Array.Array number

Basically it was to Array.get the element at an index, then increment the element at that index using Array.set. Problem was, Array.get returns Maybe a, and it took me a while to figure out that I needed to handle the case of whether or not the result of Array.get was Just a number or Nothing.

It might have been less frustrating if the compiler gave me a hint about how to handle expecting an explicit type, but actually getting a Maybe.

I'm typing this from my phone so I hope it's clear. I can clarify with some code samples later if needed.

evancz commented 6 years ago

It's clear. Thank you! The idea is:

When there is a Maybe a is not a mismatch, provide info about handling maybes.

I think it makes sense! :)