-
-
Save rl-king/f4f4037bb9f4d9fc9c0988651eb196b9 to your computer and use it in GitHub Desktop.
Code that crashes elm-make
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| ] |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This incorrect code crashes the compiler.