268 lines
4.1 KiB
Plaintext
268 lines
4.1 KiB
Plaintext
snippet mod Module definition
|
|
module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` exposing (${1})
|
|
${0}
|
|
|
|
snippet imp Import
|
|
import ${0:Http}
|
|
|
|
snippet impe Exposing import
|
|
import ${1:Html} exposing (${0:..})
|
|
|
|
snippet impae Exposing import alias
|
|
import ${1:Json.Encode} as ${2:Encode} exposing (${0:Value})
|
|
|
|
snippet fn Function
|
|
${1:fn} : ${2:a} -> ${3:a}
|
|
$1 ${4} =
|
|
${0}
|
|
|
|
snippet fnn Bi-Function
|
|
${1:fn} : ${2:a} -> ${3:a} -> ${4:a}
|
|
$1 ${5} =
|
|
${0}
|
|
|
|
snippet fnnn Tri-Function
|
|
${1:fn} : ${2:a} -> ${3:a} -> ${4:a} -> ${5:a}
|
|
$1 ${6} =
|
|
${0}
|
|
|
|
snippet var Null-Function
|
|
${1:fn} : ${2:a}
|
|
$1 =
|
|
${0}
|
|
|
|
snippet case Case
|
|
case ${1} of
|
|
${2} ->
|
|
${0}
|
|
|
|
snippet - ->
|
|
${1} ->
|
|
${0}
|
|
|
|
snippet let Let
|
|
let
|
|
${1} =
|
|
${2}
|
|
in
|
|
${0}
|
|
|
|
snippet if If-Else
|
|
if ${1} then
|
|
${2:${VISUAL}}
|
|
else
|
|
${0}
|
|
|
|
snippet ty Type
|
|
type ${1:Msg}
|
|
= ${0}
|
|
|
|
snippet tya Type alias
|
|
type alias ${1:Model} =
|
|
${0}
|
|
|
|
snippet test Test
|
|
test "${1}" <| \_ -> $0
|
|
|
|
snippet desc Description (Test)
|
|
describe "${1}" [ $0 ]
|
|
|
|
snippet doc Multiline comment
|
|
{-| ${0}
|
|
-}
|
|
|
|
snippet p Pipe
|
|
|> ${0}
|
|
|
|
snippet application Elm 0.19 application
|
|
module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` exposing (main)
|
|
|
|
import Browser
|
|
import Browser.Navigation as Nav
|
|
import Html
|
|
import Url
|
|
import Url.Parser as Parser exposing ((</>), s)
|
|
|
|
|
|
|
|
-- MAIN
|
|
|
|
|
|
main : Program () Model Msg
|
|
main =
|
|
Browser.application
|
|
{ init = init
|
|
, view = view
|
|
, update = update
|
|
, subscriptions = subscriptions
|
|
, onUrlRequest = onUrlRequest
|
|
, onUrlChange = onUrlChange
|
|
}
|
|
|
|
|
|
|
|
-- MODEL
|
|
|
|
|
|
type alias Model =
|
|
{ key : Nav.Key
|
|
, page : Page
|
|
}
|
|
|
|
|
|
type Page
|
|
= NotFound
|
|
| Root
|
|
|
|
|
|
|
|
-- SUBSCRIPTIONS
|
|
|
|
|
|
subscriptions : Model -> Sub Msg
|
|
subscriptions _ =
|
|
Sub.none
|
|
|
|
|
|
|
|
-- VIEW
|
|
|
|
|
|
view : Model -> Browser.Document Msg
|
|
view model =
|
|
case model.page of
|
|
_ ->
|
|
{ title = "Not Found"
|
|
, body = [ Html.div [] [ Html.text "Not Found" ] ]
|
|
}
|
|
|
|
|
|
|
|
-- INIT
|
|
|
|
|
|
init : () -> Url.Url -> Nav.Key -> ( Model, Cmd Msg )
|
|
init _ url key =
|
|
pageUrl url
|
|
{ key = key
|
|
, page = NotFound
|
|
}
|
|
|
|
|
|
|
|
-- UPDATE
|
|
|
|
|
|
type Msg
|
|
= NoOp
|
|
| UrlRequest Browser.UrlRequest
|
|
| UrlChanged Url.Url
|
|
|
|
|
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
|
update message model =
|
|
case message of
|
|
NoOp ->
|
|
( model, Cmd.none )
|
|
|
|
UrlRequest urlRequest ->
|
|
case urlRequest of
|
|
Browser.Internal url ->
|
|
( model, Cmd.none )
|
|
|
|
Browser.External url ->
|
|
( model, Cmd.none )
|
|
|
|
UrlChanged url ->
|
|
pageUrl url model
|
|
|
|
|
|
|
|
-- ROUTER
|
|
|
|
|
|
onUrlRequest : Browser.UrlRequest -> Msg
|
|
onUrlRequest =
|
|
UrlRequest
|
|
|
|
|
|
onUrlChange : Url.Url -> Msg
|
|
onUrlChange =
|
|
UrlChanged
|
|
|
|
|
|
pageUrl : Url.Url -> Model -> ( Model, Cmd Msg )
|
|
pageUrl url model =
|
|
let
|
|
routeParser =
|
|
Parser.oneOf
|
|
[ Parser.map Root Parser.top
|
|
]
|
|
in
|
|
case Parser.parse routeParser url of
|
|
Just page ->
|
|
( { model | page = page }
|
|
, Cmd.none
|
|
)
|
|
|
|
Nothing ->
|
|
( { model | page = NotFound }
|
|
, Cmd.none
|
|
)
|
|
|
|
|
|
snippet element Elm 0.18 element
|
|
module Main exposing (Model, Msg(..), init, main, subscriptions, update, view)
|
|
|
|
import Browser
|
|
import Html exposing (..)
|
|
import Json.Encode
|
|
|
|
|
|
main : Program Flags Model Msg
|
|
main =
|
|
Browser.element
|
|
{ init = init
|
|
, update = update
|
|
, subscriptions = subscriptions
|
|
, view = view
|
|
}
|
|
|
|
|
|
type alias Model =
|
|
{}
|
|
|
|
|
|
type alias Flags =
|
|
Json.Encode.Value
|
|
|
|
|
|
init : Flags -> ( Model, Cmd Msg )
|
|
init flags_ =
|
|
( {}
|
|
, Cmd.none
|
|
)
|
|
|
|
|
|
type Msg
|
|
= Noop
|
|
|
|
|
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
|
update msg model =
|
|
case msg of
|
|
Noop ->
|
|
( model
|
|
, Cmd.none
|
|
)
|
|
|
|
|
|
subscriptions : Model -> Sub Msg
|
|
subscriptions model =
|
|
Sub.none
|
|
|
|
|
|
view : Model -> Html Msg
|
|
view model =
|
|
h1 [] [ text "Hello, world!" ]
|