TL;DR:
If there is just Html
, it's the type (originally Html.Html
).
But if there's .
after it, it's a module name and you can take definitions from both Html
and Html.App
modules by doing Html.something
.
More in detail:
The result of import Html
is that you can access Html.whateverHtmlExposes
.
The result of the exposing (Html, button, div, text)
is that you can write
Html
instead of Html.Html
(the type),
button
instead of Html.button
(function),
- etc.
The result of import Html.App
would be that you can access Html.App.whateverHtmlAppExposes
, BUT because of the as Html
part you can now write it like Html.whateverHtmlAppExposes
.
Don't worry about conflicts - the compiler will warn you in that case:
-- NAMING ERROR ---------------------------------------------------------- C.elm
This usage of variable `A.x` is ambiguous.
9| Html.text A.x
^^^
Maybe you want one of the following?
A.x
B.x
Detected errors in 1 module.
Here I have imported B
as A
, both modules have x
exposed:
A.elm
module A exposing (x)
x = "x from A"
B.elm
module B exposing (x)
x = "x from B"
C.elm
module C exposing (..)
import A
import B as A
import Html
main = Html.text A.x