Last active
May 21, 2016 21:02
-
-
Save j-hannes/f53ca5906827bd78f76d629642f70ff9 to your computer and use it in GitHub Desktop.
Final version (without types)
This file contains hidden or 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
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