Last active
April 14, 2017 05:33
-
-
Save goofmint/d54a48efb5932ff696e080254f47e443 to your computer and use it in GitHub Desktop.
2.md
This file contains 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
-- Read more about this program in the official Elm guide: | |
-- https://guide.elm-lang.org/architecture/user_input/buttons.html | |
import Html exposing (beginnerProgram, div, button, text) | |
import Html.Events exposing (onClick) | |
main = | |
beginnerProgram { model = 0, view = view, update = update } | |
view model = | |
div [] | |
[ button [ onClick Decrement ] [ text "-" ] | |
, div [] [ text (toString model) ] | |
, button [ onClick Increment ] [ text "+" ] | |
] | |
type Msg = Increment | Decrement | |
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