Skip to content

Instantly share code, notes, and snippets.

@j-hannes
Last active May 21, 2016 21:02
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 j-hannes/f53ca5906827bd78f76d629642f70ff9 to your computer and use it in GitHub Desktop.
Save j-hannes/f53ca5906827bd78f76d629642f70ff9 to your computer and use it in GitHub Desktop.
Final version (without types)
module Counter exposing (..)
import Html exposing (button, div, span, text)
import Html.App as Html
import Html.Events exposing (onClick)
main =
Html.beginnerProgram { model = 0, view = view, update = update }
type Action
= Increment
| Decrement
update action state =
case action of
Increment ->
state + 1
Decrement ->
state - 1
view counterValue =
div []
[ button [ onClick Decrement ] [ text "-" ]
, span [] [ text (toString counterValue) ]
, button [ onClick Increment ] [ text "+" ]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment