-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example.elm
80 lines (47 loc) · 1.04 KB
/
Example.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
module Main exposing (Model, Msg(..), init, main, update, view)
import Browser
import Html exposing (Html, button, div, text)
import Html.Events as Events exposing (onClick)
-- MAIN
main =
Browser.sandbox { init = init, update = update, view = view }
-- MODEL
type alias Model =
Int
-- assign inital model to 0
init : Model
init =
0
-- UPDATE
type Msg
= Increment
| Decrement
type Update
= SoftwareUpdate
| FirmwareUpdate
update : Msg -> Model -> Model
update msg model =
let
minus =
5
in
case msg of
Increment ->
model + 1
Decrement ->
model - 1
type alias Person =
{ name : String, age : Int }
-- VIEW
view : Model -> Html Msg
view model =
let
minus =
-- this comment has a quotes, not is not a "string"
"-"
in
div []
[ button [ onClick Decrement ] [ text minus ]
, div [] [ text (String.fromInt model) ]
, button [ onClick Increment ] [ text "+" ]
]