fin/Counter.elm
Yann Esposito (Yogsototh) 35db20b196
first commit
2016-07-27 00:21:56 +02:00

26 lines
746 B
Elm

import Html exposing (Html, button, div, text)
import Html.App as Html
import Html.Events exposing (onClick)
main : Program Never
main = Html.beginnerProgram { model = model
, view = view
, update = update
}
type alias Model = Int
model : Model
model = 0
type Msg = Increment | Decrement
update : Msg -> Model -> Model
update msg model = case msg of
Increment -> model + 1
Decrement -> model - 1
view : Model -> Html Msg
view model = div []
[ button [ onClick Decrement ] [text "-"]
, div [] [text (toString model)]
, button [ onClick Increment ] [text "+"]
]