Skip to content

Instantly share code, notes, and snippets.

@rinx
Created May 30, 2017 14:37
Show Gist options
  • Save rinx/5a7c10a03a27670c138c1ef4e126c09b to your computer and use it in GitHub Desktop.
Save rinx/5a7c10a03a27670c138c1ef4e126c09b to your computer and use it in GitHub Desktop.
my first elm sample
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