Last active
November 27, 2016 15:51
-
-
Save richard-uk1/39e9ea9e1a3330edfce7120769519c61 to your computer and use it in GitHub Desktop.
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 | |
import Html.Events as HtmlEvt | |
main = | |
Html.beginnerProgram | |
{ model = init | |
, view = view | |
, update = update | |
} | |
-- Model | |
type alias Model = Int | |
init : Model | |
init = | |
0 | |
-- UPDATE | |
type Msg = Increment | Decrement | |
update : Msg -> Model -> Model | |
update msg model = | |
case msg of | |
Increment -> | |
model + 1 | |
Decrement -> | |
model - 1 | |
-- VIEW | |
view : Model -> Html.Html Msg | |
view model = | |
Html.div [] | |
[ Html.button [ HtmlEvt.onClick Decrement ] [ Html.text "-" ] | |
, Html.div [] [ Html.text (toString model) ] | |
, Html.button [ HtmlEvt.onClick Increment ] [ Html.text "+" ] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment