Created
May 30, 2017 14:37
-
-
Save rinx/5a7c10a03a27670c138c1ef4e126c09b to your computer and use it in GitHub Desktop.
my first elm sample
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
module Main exposing (..) | |
import Html exposing (..) | |
import Html.Events exposing (..) | |
import Html.Attributes exposing (..) | |
type alias Model = Int | |
type Msg = Click | |
main : Program Never Model Msg | |
main = Html.program | |
{ init = init | |
, view = view | |
, update = update | |
, subscriptions = subscriptions | |
} | |
subscriptions : Model -> Sub Msg | |
subscriptions model = Sub.none | |
init : (Model, Cmd Msg) | |
init = 0 ! [] | |
update : Msg -> Model -> (Model, Cmd Msg) | |
update msg model = | |
case msg of | |
Click -> (model + 1) ! [] | |
view : Model -> Html Msg | |
view model = | |
let | |
cnt = toString model |> text | |
in | |
div [onClick Click] [cnt] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment