-
-
Save MarkNijhof/a52f4359a7ade6fb086eecc8df752cb1 to your computer and use it in GitHub Desktop.
Elm Counter Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main exposing (..) | |
import Html exposing (br, button, div, text) | |
import Html.Events exposing (onClick) | |
import Html.App exposing (beginnerProgram) | |
main : Program Never | |
main = | |
beginnerProgram { model = model, view = view, update = update } | |
type Msg | |
= Increment | |
| Decrement | |
model : Int | |
model = | |
0 | |
view : Int -> Html.Html Msg | |
view model = | |
div [] | |
[ button [ onClick Increment ] [ text "+" ] | |
, br [] [] | |
, text (toString model) | |
, br [] [] | |
, button [ onClick Decrement ] [ text "-" ] | |
] | |
update : Msg -> Int -> Int | |
update msg model = | |
case msg of | |
Increment -> | |
model + 1 | |
Decrement -> | |
model - 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment