(.module: [library [lux #* [abstract ["." monad (#+ do)]] [control ["." try (#+ Try)] [concurrency ["." async (#+ Async)]]] [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 Async) file.Path (Async (List file.Path))) (let [! async.monad] (|> path (\ fs sub_directories) (\ ! map (|>> (try.else (list)) (monad.map ! (targets fs)))) (\ ! join) (\ ! map (|>> list.joined (list& path)))))) (def: .public delay Nat 1,000) (def: (pause delay) (-> Nat (Async (Try Any))) (async.delayed 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 (get@ #///.sources) set.list (monad.map ! (..targets fs)) (\ ! map list.joined))] (do {! ///action.monad} [_ (monad.map ! (\ watcher start watch.modification) targets) _ ] (loop [_ []] (do ! [_ (..pause delay) events (\ watcher poll [])] (case events (#.Item _) (do ! [_ ] (recur [])) #.End (recur []))))))))))