(.module: [library [lux "*" [abstract ["[0]" monad {"+" [do]}]] [control ["[0]" try {"+" [Try]}] [concurrency ["[0]" async {"+" [Async]}]]] [data [collection ["[0]" list] ["[0]" set]]] [world [program {"+" [Program]}] [shell {"+" [Exit Shell]}] [console {"+" [Console]}] ["[0]" file ["[0]" watch {"+" [Watcher]}]]]]] ["[0]" // "_" ["/[1]" // "_" [command {"+" [Command]}] ["[1]" profile] ["[1][0]" action] [dependency [resolution {"+" [Resolution]}]]]]) (def: (targets fs path) (-> (file.System Async) file.Path (Async (List file.Path))) (let [! async.monad] (|> path (\ fs sub_directories) (\ ! each (|>> (try.else (list)) (monad.each ! (targets fs)))) (\ ! conjoint) (\ ! each (|>> list.together (list& path)))))) (def: .public delay Nat 1,000) (def: (pause delay) (-> Nat (Async (Try Any))) (async.after delay {try.#Success []})) (def: .public (do! delay watcher command) (All (_ a) (-> Nat (Watcher Async) (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit a])) (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit Any])))) (function (_ console program fs shell resolution) (function (_ profile) (with_expansions [ ((command console program fs shell resolution) profile)] (do [! async.monad] [targets (|> profile (value@ ///.#sources) set.list (monad.each ! (..targets fs)) (\ ! each list.together))] (do [! ///action.monad] [_ (monad.each ! (\ watcher start watch.modification) targets) _ ] (loop [_ []] (do ! [_ (..pause delay) events (\ watcher poll [])] (case events {.#Item _} (do ! [_ ] (recur [])) {.#End} (recur []))))))))))