-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtodo.elm
59 lines (45 loc) · 1.04 KB
/
todo.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
52
53
54
55
56
57
58
59
module Todo exposing ( main )
import HtmlHelper exposing ( li_, ul_, div_ )
import Todo.Tasks as Tasks
import Html.App as App
import Html exposing ( Html, div )
main =
App.beginnerProgram { model = init
, view = view
, update = update }
-- Model
type alias Tasks = Tasks.Model
type alias Model =
{ tasks : Tasks
}
init : Model
init =
{ tasks = emptyTasks
}
emptyTasks : Tasks
emptyTasks = Tasks.init
-- Update
type Msg
= TasksMsg Tasks.Msg
update : Msg -> Model -> Model
update message ({ tasks } as model) =
case message of
TasksMsg msg ->
{ model | tasks = Tasks.update msg tasks }
-- View
view : Model -> Html Msg
view ({tasks} as model) =
div_
[ newTaskButton
, listView tasks
]
-- View / helpers
listView : Tasks -> Html Msg
listView =
liftHtmlTasksMsgToHtmlMsg << Tasks.listView
newTaskButton : Html Msg
newTaskButton =
liftHtmlTasksMsgToHtmlMsg Tasks.newButton
liftHtmlTasksMsgToHtmlMsg : Html Tasks.Msg -> Html Msg
liftHtmlTasksMsgToHtmlMsg =
App.map TasksMsg