Created
February 29, 2020 17:24
-
-
Save jbmilgrom/baddfa2e56f17a3e047905caca86b2ee to your computer and use it in GitHub Desktop.
Counter example from https://guide.elm-lang.org/
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
import Browser | |
import Html exposing (Html, button, div, text) | |
import Html.Events exposing (onClick) | |
main = | |
Browser.sandbox { init = 0, update = update, view = view } | |
type Msg = Increment | Decrement | |
update msg model = | |
case msg of | |
Increment -> | |
model + 1 | |
Decrement -> | |
model - 1 | |
view model = | |
div [] | |
[ button [ onClick Decrement ] [ text "-" ] | |
, div [] [ text (String.fromInt model) ] | |
, button [ onClick Increment ] [ text "+" ] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment