Skip to content

Instantly share code, notes, and snippets.

@roine
Last active April 16, 2017 20:32
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 roine/c0e920ef851d0bff3217b54a8040cc85 to your computer and use it in GitHub Desktop.
Save roine/c0e920ef851d0bff3217b54a8040cc85 to your computer and use it in GitHub Desktop.
bare minimum elm architechure for Elm 0.18
module Main exposing (..)
import Html exposing (..)
-- MODEL
type alias Model =
{ key : Int }
init : ( Model, Cmd Msg )
init =
( initialModel, Cmd.none )
initialModel : Model
initialModel =
{ key = 1 }
-- UPDATE
type Msg
= NoOp
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
NoOp ->
model ! []
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.batch []
-- VIEW
view : Model -> Html Msg
view model =
div [] [ text "hello world" ]
-- INIT
main =
program
{ init = init
, update = update
, subscriptions = subscriptions
, view = view
}
module Main exposing (..)
import Html exposing (..)
-- MODEL
type alias Model =
{ key : Int }
model : Model
model =
{ key = 1 }
-- UPDATE
type Msg
= NoOp
update : Msg -> Model -> Model
update msg model =
case msg of
NoOp ->
model
-- VIEW
view : Model -> Html Msg
view model =
div [] [ text "hello world" ]
-- INIT
main =
beginnerProgram
{ model = model
, update = update
, view = view
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment