はい、これは新しい型を宣言しUpdate
ます。縦棒は「or」と読むことができます。つまり、何かの型Update
は次のいずれかになります。
- a
First
、型のデータが含まれていますField.Content
- a
Last
、型のデータが含まれていますField.Content
- an
Email
、型のデータが含まれていますField.Content
- a
Remail
、型のデータが含まれていますField.Content
- または、
Submit
対応するデータがありません。
type の値を処理するには、 -構文をUpdate
使用して、可能なさまざまな値を区別できます。case
of
update : Update -> State -> State
update upd st = case upd of
First content -> st -- do something in the situation that the Update is a First
Last content -> st -- do something in the situation that the Update is a Last
Email content -> st -- do something in the situation that the Update is a Email
Remail content -> st -- do something in the situation that the Update is a Remail
Submit -> st -- do something in the situation that the Update is a Submit
Elm Web サイトのドキュメントへのリンクを追加しますが、新しい 0.14 リリースに向けて書き直しています。後で戻って編集するかもしれません;)