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

intuitive usage of a function #240

Open ShalokShalom opened 7 years ago

ShalokShalom commented 7 years ago

I am following the tutorial, which says

isNegative n = n < 0

I tried to do it intuitive, as a newbie to programming:

isNegative n < 0
-- NAMING ERROR ---------------------------------------------- repl-temp-000.elm

Cannot find variable `n`

3|   isNegative n < 0
                ^
Maybe you want one of the following?

    e
    Basics.e

What means this message? It is maybe appropriate to link a nice tutorial, which shows to usage of functions?

manveru commented 6 years ago

This means you have tried to call a function called isNegative with an argument n < 0. Elm doesn't find a variable called n, and suggests alternatives that are also one letter and comparable to 0, so it finds the constant e.

What you actually wanted to do is write isNegative 0 or isNegative 23 or isNegative -42.

Hopefully the error message here will be improved, since it makes no sense to call isNegative with a boolean argument anyway.

ShalokShalom commented 6 years ago

Thanks a lot.