Last active
July 21, 2016 22:25
-
-
Save jesperp/8a3f691f1ed70de8fd317497278b1f5f to your computer and use it in GitHub Desktop.
This file contains 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 | |
import Html.App | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (onClick) | |
type alias Model = Int | |
type Msg = Increment | Decrement | Reset | Set Int | |
update : Msg -> Model -> (Model, Cmd Msg) | |
update msg model = | |
case msg of | |
Increment -> (model + 1, Cmd.none) | |
Decrement -> (model - 1, Cmd.none) | |
Set value -> (value, Cmd.none) | |
Reset -> (0, Cmd.none) | |
view : Model -> Html.Html Msg | |
view model = | |
Html.div | |
[] | |
[ Html.h1 [] [Html.text <| toString model] | |
, Html.br [] [] | |
, Html.button [onClick Increment] [Html.text "Increment"] | |
, Html.button [onClick Decrement] [Html.text "Decrement"] | |
, Html.button [onClick Reset] [Html.text "Reset"] | |
] | |
main : Program Never | |
main = | |
Html.App.program | |
{ init = (0, Cmd.none) | |
, subscriptions = (\_ -> Sub.none) | |
, update = update | |
, view = view | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment