Created
November 27, 2015 01:03
-
-
Save spg/cdcfeda5f796a35040eb to your computer and use it in GitHub Desktop.
Elm counter
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
import Html exposing (div, button, text, input) | |
import Html.Events exposing (onClick) | |
import StartApp.Simple as StartApp | |
main = | |
StartApp.start { model = model, view = view, update = update } | |
model = 0 | |
view address model = | |
div [] | |
[ button [ onClick address Decrement ] [ text "-" ] | |
, div [] [ text (toString model) ] | |
, button [ onClick address Increment ] [ text "+" ] | |
, button [ onClick address Reset ] [ text "reset" ] | |
, input [ type "file" ] [ text "Select file" ] | |
] | |
type Action = Increment | Decrement | Reset | |
update action model = | |
case action of | |
Increment -> model + 1 | |
Decrement -> model - 1 | |
Reset -> 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment