Skip to content

Instantly share code, notes, and snippets.

@kristiannissen
Created June 2, 2016 06:31
Show Gist options
  • Select an option

  • Save kristiannissen/ec36b84af6b328968d0499a7c9a31398 to your computer and use it in GitHub Desktop.

Select an option

Save kristiannissen/ec36b84af6b328968d0499a7c9a31398 to your computer and use it in GitHub Desktop.
1st Elm app
Detected errors in 1 module.
-- SYNTAX PROBLEM -------------------------------------------------- counter.elm
I ran into something unexpected when parsing your code!
33| model = 0
^
I am looking for one of the following things:
end of input
whitespace
import Html exposing (Html, button, div, text)
import Html.App as Html
import Html.Events exposing (onClick)
main =
Html.beginnerProgram { model = model, view = view, update = update }
-- MODEL
type alias Model = Int
model : Model
model =
0
-- UPDATE
type Msg = Increment | Decrement | Reset
update : Msg -> Model -> Model
update msg model =
case msg of
Increment ->
model + 1
Decrement ->
model - 1
Reset ->
model = 0
-- VIEW
view : Model -> Html Msg
view model =
div [] [
button [ onClick Decrement ] [ text "-" ]
, div [] [text (toString model)]
, button [onClick Increment][ text "+" ]
, button [onClick Reset][ text "reset" ]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment