Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Oct 11th, 2018 61 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. port module Buttons exposing (main)
  2.  
  3. import Html exposing (Html, button, div, text)
  4. import Html.Events exposing (onClick)
  5.  
  6.  
  7. main =
  8.     Html.beginnerProgram { model = model, view = view, update = update }
  9.  
  10.  
  11.  
  12. -- MODEL
  13.  
  14.  
  15. type alias Model =
  16.     Int
  17.  
  18.  
  19. model : Model
  20. model =
  21.     0
  22.  
  23.  
  24.  
  25. -- UPDATE
  26.  
  27.  
  28. type Msg
  29.     = Increment
  30.     | Decrement
  31.  
  32.  
  33. update : Msg -> Model -> Model
  34. update msg model =
  35.     case msg of
  36.         Increment ->
  37.             model + 1
  38.  
  39.         Decrement ->
  40.             model - 1
  41.  
  42.  
  43.  
  44. -- VIEW
  45.  
  46.  
  47. view : Model -> Html Msg
  48. view model =
  49.     div []
  50.         [ button [ onClick Decrement ] [ text "-" ]
  51.         , div [] [ text (toString model) ]
  52.         , button [ onClick Increment ] [ text "+" ]
  53.         ]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top