Skip to content

Instantly share code, notes, and snippets.

@chrisbuttery
Last active May 18, 2016 05:51
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 chrisbuttery/1d6a51fc15a4c461880b3acc225ba050 to your computer and use it in GitHub Desktop.
Save chrisbuttery/1d6a51fc15a4c461880b3acc225ba050 to your computer and use it in GitHub Desktop.
Elm 0.17. A simple 'mouse clicks' example
"version": "1.0.0",
"summary": "let people do a cool thing in a fun way",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "4.0.0 <= v < 5.0.0",
"elm-lang/html": "1.0.0 <= v < 2.0.0",
"elm-lang/mouse": "1.0.0 <= v < 2.0.0",
},
"elm-version": "0.17.0 <= v < 0.18.0"
}
import Html exposing (Html, text, div)
import Html.App as Html
import Mouse exposing (..)
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}
-- MODEL
type alias Model = Float
init : (Model, Cmd Msg)
init =
(0, Cmd.none)
-- UPDATE
type Msg
= Click
update msg model =
case msg of
Click ->
(model + 1 , Cmd.none)
-- SUBSCRIPTIONS
subscriptions model =
Mouse.clicks (\_ -> Click)
-- VIEW
view model =
Html.text (toString model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment