Skip to content

Instantly share code, notes, and snippets.

@lydell
Last active September 21, 2016 09:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lydell/37634f349a1e1d3808cca43234496653 to your computer and use it in GitHub Desktop.
Save lydell/37634f349a1e1d3808cca43234496653 to your computer and use it in GitHub Desktop.
Crazy elm
module Main exposing (..)
import Html exposing (Html, div, button, text)
import Html.App
import Html.Events exposing (onClick)
main : Program Never
main =
Html.App.beginnerProgram
{ model = 0
, update = always
, view = view
}
view : Int -> Html Int
view count =
div []
[ button [ onClick (count - 1) ] [ text "-" ]
, text (toString count)
, button [ onClick (count + 1) ] [ text "+" ]
]
import Html exposing (..)
import Html.App exposing (..)
import Html.Events exposing (..)
main =
beginnerProgram
{ model = 0
, update = always
, view = v
}
v c =
[ button [ c - 1 |> onClick ] [ text "-" ]
, c |> text << toString
, button [ c + 1 |> onClick ] [ text "+" ]
]
|> (div <| [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment