Skip to content

Instantly share code, notes, and snippets.

@goofmint
Last active April 14, 2017 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goofmint/d54a48efb5932ff696e080254f47e443 to your computer and use it in GitHub Desktop.
Save goofmint/d54a48efb5932ff696e080254f47e443 to your computer and use it in GitHub Desktop.
2.md
-- 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