Files
olla/content/talks/afup-tours-programmation-fonctionnelle/Main.elm
2026-02-18 17:23:24 +01:00

26 lines
704 B
Elm

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 ]
]