-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ylm.elm
52 lines (40 loc) · 1 KB
/
Ylm.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module Ylm exposing (..)
import List
import Maybe
import Html
import Html.App
import Html.Events
type Msg =
Noop
| ButtonClicked
type alias Model =
{ strings : List String }
model0 : Model
model0 =
{ strings = [ "qwert", "asdf", "zxcv", "puss" ] }
updateStrings : List String -> List String
updateStrings strings =
case strings of
hd::tl -> List.append tl [hd]
[] -> []
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
Noop -> (model, Cmd.none)
ButtonClicked -> ({ strings = updateStrings model.strings }, Cmd.none)
view : Model -> Html.Html Msg
view model =
Html.div []
[ Html.text <| Maybe.withDefault "error" <| List.head model.strings
, Html.br [] []
, Html.button [ Html.Events.onClick ButtonClicked ] [ Html.text "button" ]
]
subscriptions : Model -> Sub Msg
subscriptions model = Sub.none
main : Program Never
main = Html.App.program
{ init = (model0, Cmd.none)
, update = update
, subscriptions = subscriptions
, view = view
}