Skip to content

Instantly share code, notes, and snippets.

@rl-king
Created August 25, 2017 18:25
Show Gist options
  • Select an option

  • Save rl-king/f4f4037bb9f4d9fc9c0988651eb196b9 to your computer and use it in GitHub Desktop.

Select an option

Save rl-king/f4f4037bb9f4d9fc9c0988651eb196b9 to your computer and use it in GitHub Desktop.
Code that crashes elm-make
module Main exposing (..)
import Html
import Navigation exposing (Location)
import UrlParser as Url exposing (..)
main : Program Never Model Msg
main =
Navigation.program UrlChange
{ init = init
, view = view
, update = update
, subscriptions = \x -> Sub.none
}
type alias Model =
{ route : Route
}
init : Navigation.Location -> ( Model, Cmd Msg )
init location =
{ route = parseLocation location
}
! []
type Msg
= NoOp
| UrlChange Location
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
NoOp ->
model ! []
UrlChange location ->
{ model | route = parseLocation location } ! []
view : Model -> Html.Html Msg
view model =
Html.div [] [ Html.text "hello" ]
parseLocation : Location -> Route
parseLocation location =
location
|> Url.parsePath route
|> Maybe.withDefault Home
type Route
= Home
| Page
route : Url.Parser (Route -> a) a
route =
Url.oneOf
[ Url.map Home top
, Url.map Page s </> string
]
@rl-king
Copy link
Author

rl-king commented Aug 25, 2017

This incorrect code crashes the compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment