Skip to content

Instantly share code, notes, and snippets.

@stevekrouse
Created August 10, 2018 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevekrouse/5d763977c620c590d9f3434231348c76 to your computer and use it in GitHub Desktop.
Save stevekrouse/5d763977c620c590d9f3434231348c76 to your computer and use it in GitHub Desktop.
module Main exposing (main)
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
type alias Model =
{ count : Int }
initialModel : Model
initialModel =
{ count = 0 }
type Msg
= Increment
| Decrement
update : Msg -> Model -> Model
update msg model =
case msg of
Increment ->
{ model | count = model.count + 1 }
Decrement ->
{ model | count = model.count - 1 }
view : Model -> Html Msg
view model =
div []
[ button [ onClick Increment ] [ text "+1" ]
, div [] [ text <| toString model.count ]
, button [ onClick Decrement ] [ text "-1" ]
]
main : Program Never Model Msg
main =
Html.beginnerProgram
{ model = initialModel
, view = view
, update = update
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment