blob: 2460215b47c6bd2b733d186b6649e3a9b594815d (
plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
(.module:
[library
[lux #*
[abstract
["." monad (#+ do)]]
[control
["." try (#+ Try)]
[concurrency
["." promise (#+ Promise)]]]
[data
[collection
["." list]
["." set]]]
[world
[program (#+ Program)]
[shell (#+ Exit Shell)]
[console (#+ Console)]
["." file
["." watch (#+ Watcher)]]]]]
["." // #_
["/#" // #_
[command (#+ Command)]
["#" profile]
["#." action]
[dependency
[resolution (#+ Resolution)]]]])
(def: (targets fs path)
(-> (file.System Promise) file.Path (Promise (List file.Path)))
(let [! promise.monad]
(|> path
(\ fs sub_directories)
(\ ! map (|>> (try.default (list))
(monad.map ! (targets fs))))
(\ ! join)
(\ ! map (|>> list.concat (list& path))))))
(def: #export delay
Nat
1,000)
(def: (pause delay)
(-> Nat (Promise (Try Any)))
(promise.delay delay (#try.Success [])))
(def: #export (do! delay watcher command)
(All [a]
(-> Nat (Watcher Promise)
(-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit a]))
(-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit Any]))))
(function (_ console program fs shell resolution)
(function (_ profile)
(with_expansions [<call> ((command console program fs shell resolution) profile)]
(do {! promise.monad}
[targets (|> profile
(get@ #///.sources)
set.to_list
(monad.map ! (..targets fs))
(\ ! map list.concat))]
(do {! ///action.monad}
[_ (monad.map ! (\ watcher start watch.modification) targets)
_ <call>]
(loop [_ []]
(do !
[_ (..pause delay)
events (\ watcher poll [])]
(case events
(#.Cons _)
(do !
[_ <call>]
(recur []))
#.Nil
(recur []))))))))))
|