type alias Model =
String
Here we define what our application’s model will look like. In this case, we are aliasing the built-in String
type. So our whole application’s model is simply a string.
Our application’s model can be any type of value supported by Elm, including:
init : ( Model, Cmd Msg )
init =
( "Hello", Cmd.none )
init
is a function that returns the initial state of the application. The first line init : ( Model, Cmd msg )
is the function’s type signature. This is saying that init
returns a tuple, containing a Model
and a Cmd Msg
.
Cmd
)A command is how we tell the Elm runtime to perform a side effect. Here are some of the side effects supported by the Elm Runtime:
Each of these is represented by a value with a type of Cmd
.
Our program’s init
function has an opportunity to return a command to be performed when our program first starts. In this example, we don’t need Elm to do anything at start-up, so we return Cmd.none
.