Skip to content

Instantly share code, notes, and snippets.

@aceakash
Last active June 29, 2017 15:49
Show Gist options
  • Save aceakash/62baa2c66e6415c7980f4ecb02154a9b to your computer and use it in GitHub Desktop.
Save aceakash/62baa2c66e6415c7980f4ecb02154a9b to your computer and use it in GitHub Desktop.
Elm boilerplate
module Main exposing (..)
import Html exposing (Html, button, div, h1, text)
import Html.Events exposing (onClick)
main =
Html.program
{ init = ( initialModel, Cmd.none )
, view = view
, update = update
, subscriptions = subscriptions
}
-- MODEL
type alias Model =
Int
initialModel : Model
initialModel =
0
-- UPDATE
type Msg
= Increment
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
Increment ->
( model + 1, Cmd.none )
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
-- VIEW
view : Model -> Html Msg
view model =
div []
[ h1 [] [ text (toString model) ]
, button [ onClick Increment ] [ text "Increment" ]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment