Skip to content

Instantly share code, notes, and snippets.

@andeemarks
Created February 17, 2018 06:09
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 andeemarks/83eb510b870a8bf9828c219f8885e34d to your computer and use it in GitHub Desktop.
Save andeemarks/83eb510b870a8bf9828c219f8885e34d to your computer and use it in GitHub Desktop.
import Html exposing (Html, text, div)
import Mouse exposing (..)
main = Html.program { init = init,
view = view, update = update, subscriptions = subscriptions }
-- Model
type alias Model = { count: Int }
initialModel : Model
initialModel = { count = 0 }
init = (initialModel, Cmd.none)
-- Update
type Msg = Position Int Int
update: Msg -> Model -> (Model, Cmd a)
update msg model = case msg of
Position x y -> ({model | count = model.count + 1}, Cmd.none)
-- Subscriptions
subscriptions: Model -> Sub Msg
subscriptions model = Mouse.moves(\{x, y} -> Position x y)
-- View
-- view: Model -> Html div
view model = div [] [text (toString model)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment