Elm LanguageDebugging


Syntax

  • Debug.log "tag" anyValue

Remarks

Debug.log takes two parameters, a String to tag the debug output in the console (so you know where it's coming from / what the message corresponds to), and a value of any type. Debug.log executes the side-effect of logging the tag and the value to the JavaScript console, and then returns the value. The implementation in JS might look something like:

function log (tag, value){
    console.log(tag, value);
    return value
}

JavaScript has implicit conversions, so value doesn't have to be explicitly converted to a String for the above code to work. However, Elm types must be explicitly converted to a String, and the Native code for Debug.log shows this in action.