-
Notifications
You must be signed in to change notification settings - Fork 3
/
Main.elm
56 lines (36 loc) · 1.02 KB
/
Main.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
module Main where
import Html exposing (Html)
import Task exposing (Task)
import Model exposing (Model, ExportModel, initialModel, modelToExportModel)
import Update exposing (update, Action(NoOp, Init))
import View exposing (show)
import Export.History
import Import.History
import Version
port path : Signal.Signal String
setModelAction : Signal.Signal Action
setModelAction =
Signal.map Import.History.fromPath path
|> Signal.map Init
mb : Signal.Mailbox Action
mb =
Signal.mailbox NoOp
actionSignal : Signal.Signal Action
actionSignal =
Signal.mergeMany
[ mb.signal
, setModelAction
]
modelSignal : Signal.Signal Model
modelSignal =
Signal.foldp update initialModel actionSignal
exportModelSignal : Signal.Signal ExportModel
exportModelSignal =
Signal.map modelToExportModel modelSignal
|> Signal.dropRepeats
main : Signal.Signal Html
main =
Signal.map (show mb.address) modelSignal
port newPath : Signal.Signal String
port newPath =
Signal.map Export.History.toPath exportModelSignal