Skip to content

Instantly share code, notes, and snippets.

@mhanberg
Created March 8, 2018 23:26
Show Gist options
  • Save mhanberg/f54f9f7486f116353ad9cbd2b734a856 to your computer and use it in GitHub Desktop.
Save mhanberg/f54f9f7486f116353ad9cbd2b734a856 to your computer and use it in GitHub Desktop.
elm-snippet-building-with-elm-at-sep-makes
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
main =
Html.beginnerProgram { model = 0, view = view, update = update }
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 (toString model) ]
, button [ onClick Increment ] [ text "+" ]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment