Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions snippets/elm-mode/function
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: function
# uuid:
# key: :fn
# condition: t
# --

$1 : $2
$1 ${$3} =
$0
66 changes: 66 additions & 0 deletions snippets/elm-mode/main
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# -*- mode: snippet -*-
# name: main
# key: trigger-key
# condition: t
# --

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that really the minimal main module that everyone would start with?
Seems a bit much to me tbh

module Main exposing (main)

import Browser exposing (Document, UrlRequest, application)
import Browser.Navigation as Nav
import Html
import Url exposing (Url)


type alias Model =
{ key : Nav.Key
, url : Url
}


init : () -> Url -> Nav.Key -> ( Model, Cmd Msg )
init _ url key =
( Model key url, Cmd.none )


main =
application
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
, onUrlChange = UrlChanged
, onUrlRequest = UrlRequested
}


subscriptions : Model -> Sub Msg
subscriptions _ =
Sub.none


type Msg
= UrlChanged Url
| UrlRequested UrlRequest


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
UrlChanged newUrl ->
( { model | url = newUrl }, Cmd.none )

UrlRequested urlRequest ->
case urlRequest of
Browser.Internal url ->
( model, Nav.pushUrl model.key (Url.toString url) )

Browser.External href ->
( model, Nav.load href )


view : Model -> Document Msg
view model =
{ title = "Elm App"
, body = [ Html.p [] [ Html.text "hello, world" ] ]
}