Values in Elm
Elm has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
To run this Elm program, you would typically compile it to JavaScript and then run it in a browser. Here’s what the output would look like:
In Elm, we don’t have a direct equivalent of fmt.Println
. Instead, we create an HTML structure and use the text
function to display strings. We also use String.fromInt
, String.fromFloat
, and String.fromBool
to convert other types to strings for display.
Note that in Elm, string concatenation is done with ++
instead of +
. Also, Elm is a purely functional language, so we define a main
function that returns an HTML structure, rather than having a series of statements that print to the console.