Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Main exposing (..)
- import Html exposing (Html, div, text, program)
- import Keyboard
- import Mouse
- import Char
- -- MODEL
- type alias Model =
- String
- init : ( Model, Cmd Msg )
- init =
- ( "Hello", Cmd.none )
- -- MESSAGES
- type Msg
- = MouseMsg Mouse.Position
- | KeyMsg Keyboard.KeyCode
- -- VIEW
- view : Model -> Html Msg
- view model =
- div []
- [ text model ]
- -- UPDATE
- update : Msg -> Model -> ( Model, Cmd Msg )
- update msg model =
- case msg of
- MouseMsg position ->
- ( model ++ ", " ++ toString position, Cmd.none )
- KeyMsg x ->
- ( model ++ toString (Char.fromCode x), Cmd.none )
- -- SUBSCRIPTIONS
- subscriptions : Model -> Sub Msg
- subscriptions model =
- Sub.batch
- [ Keyboard.downs KeyMsg
- , Mouse.clicks MouseMsg
- ]
- -- MAIN
- main : Program Never Model Msg
- main =
- program
- { init = init
- , view = view
- , update = update
- , subscriptions = subscriptions
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement