Union, : .
type Msg
= NoOp
| SomeMessage Int String
Msg , :
update: Msg -> Model -> ( Model, Cmd Msg )
NoOp SomeMessage - Msg
, SomeMessage :
createSomeMessage: Int -> Msg
createSomeMessage number =
SomeMessage number "Hello!"
createSomeMessage 1 -- SomeMessage 1 "Hello!"
Union
Elm Partial Application, , Msg, .
:
-- Partially applied value constructor, which expects new argument
messageWithId : String -> Msg
messageWithId =
SomeMessage 1
{- Later in the view, (SomeMessage 1) will wait for the String from the
input DOM event
-}
input [ onInput messageWithId ] []
-- Alternative way to express the same thing:
input [ onInput (SomeMessage 1) ] []
, , DOM. .
example .