Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Main exposing (..)
- import Html exposing (..)
- import Html.Attributes exposing (..)
- import Html.Events exposing (..)
- import Html.App as App
- import String
- -- model
- type alias Model =
- String
- initModel : Model
- initModel =
- ""
- -- update
- type Msg
- = ChangeInput String
- nextInput : String -> String -> String
- nextInput current new =
- case String.toInt new of
- Ok _ ->
- new
- Err _ ->
- if new == "" then
- new
- else
- current
- update : Msg -> Model -> Model
- update msg model =
- case msg of
- ChangeInput newInput ->
- nextInput model newInput
- -- view
- view : Model -> Html Msg
- view model =
- div []
- [ input
- [ type' "text"
- , value model
- , onInput ChangeInput
- ]
- []
- ]
- main : Program Never
- main =
- App.beginnerProgram
- { model = initModel
- , update = update
- , view = view
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement