import Browser
import Html exposing (Html, Attribute, button, div, text, input)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)

main =
  Browser.sandbox { init = init, update = update, view = view }

type alias Model = String
type Event = NewName String-- | Reverse

init : Model
init = "Thibaud"

update : Event -> Model -> Model
update event oldName = case event of
    NewName newName -> newName
    -- Reverse -> String.reverse oldName

view : Model -> Html Event
view name =
    div []
        [ input [ placeholder "New Name", onInput NewName, value name ] []
        , button [ onClick Reverse ] [ text "Reverse Name" ]
        , div [] [ text name ]
        ]