Created
May 16, 2016 01:03
-
-
Save jwthomp/46982edfc6b5bd94ec77eee0887f8de8 to your computer and use it in GitHub Desktop.
Main.elm
This file contains 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
import Html exposing (..) | |
import Html.App exposing (beginnerProgram, program) | |
import Html.Events exposing (onClick) | |
import Task | |
import Debug | |
type alias Model = Int | |
type Msg | |
= Hello | |
| Bye | |
| Fail | |
| NotFail | |
init : Int -> (Model, Cmd Msg) | |
init value = | |
(value, Cmd.none) | |
view : Model -> Html Msg | |
view model = | |
div [] | |
[ text <| toString model | |
, button [ onClick Hello ] [ text "Hello" ] | |
] | |
update : Msg -> Model -> (Model, Cmd Msg) | |
update message model = | |
case message of | |
Hello -> (model, Task.perform Fail Bye) | |
Fail -> (model, Cmd.none) | |
NotFail -> (model, Cmd.none) | |
Bye -> (model, Cmd.none) | |
main = | |
program | |
{ init = init 2 | |
, update = update | |
, view = view | |
, subscriptions = \_ -> Sub.none | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment