Types

    The following code defines a function which extracts a persons full name as a string:

    In JavaScript, the equivalent code spits out "undefined Hesse". Not even an error! Hopefully one of your users will tell you about it when they see it in the wild. In contrast, the Elm compiler just looks at the source code and tells you:

    1. -- TYPE MISMATCH ---------------------------------------------------------------
    2. The argument to function `toFullName` is causing a mismatch.
    3. Function `toFullName` is expecting the argument to be:
    4. { …, firstName : }
    5. Hint: I compared the record fields and found some potential typos.

    It is great to have an assistant for simple mistakes like this, but it is even more valuable when you have hundreds of files and a bunch of collaborators making changes. No matter how big and complex things get, the Elm compiler checks that everything fits together properly just based on the source code.