Reading Note: Elm module


Elm Module

A simple main module in Elm:

module Main exposing (main)
import Html exposing (Html, text)

main : Html msg
main =
  text "Hello, Elm"

The main constant name is important but not the module’s name. You could call your main module name Greenday.

module Greenday exposing (main)

However, if you change the name of the main constant. Elm will raise an error when you build your main module.

module Greenday exposing (wakeMeUpWhenSeptemperEnds)
import Html exposing (Html, text)

wakeMeUpWhenSeptemperEnds : Html msg
wakeMeUpWhenSeptemperEnds =
  text "Hello, Elm"

Try the code above and see what happens.

Small quiz

You could see that the type annotation of our main module is Html msg. Why?