From 2b909032e7a0bd10cd7db52067d2fb701bfa95e5 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 6 Jul 2021 21:34:21 -0400 Subject: Simplified the API for file-system operations. --- stdlib/source/program/aedifex/command/auto.lux | 45 +++++++++++--------------- 1 file changed, 19 insertions(+), 26 deletions(-) (limited to 'stdlib/source/program/aedifex/command/auto.lux') diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux index 5f3d95631..398fb26cf 100644 --- a/stdlib/source/program/aedifex/command/auto.lux +++ b/stdlib/source/program/aedifex/command/auto.lux @@ -13,32 +13,26 @@ [world [program (#+ Program)] [shell (#+ Shell)] - ["." console (#+ Console)] - ["." file (#+ Path) + [console (#+ Console)] + ["." file ["." watch (#+ Watcher)]]]] ["." // #_ ["/#" // #_ [command (#+ Command)] ["#" profile] - ["#." action (#+ Action)] + ["#." action] [dependency [resolution (#+ Resolution)]]]]) (def: (targets fs path) - (-> (file.System Promise) Path (Promise (List Path))) - (do {! promise.monad} - [?root (\ fs directory [path])] - (case ?root - (#try.Success root) - (loop [root root] - (do ! - [subs (\ ! map (|>> (try.default (list))) - (\ root directories []))] - (\ ! map (|>> list.concat (list& (\ root scope))) - (monad.map ! recur subs)))) - - (#try.Failure error) - (wrap (list))))) + (-> (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 @@ -68,13 +62,12 @@ (loop [_ []] (do ! [_ (..pause delay) - events (\ watcher poll []) - _ (case events - (#.Cons _) - (do ! - [_ ] - (wrap [])) + events (\ watcher poll [])] + (case events + (#.Cons _) + (do ! + [_ ] + (recur [])) - #.Nil - (wrap []))] - (recur []))))))))) + #.Nil + (recur [])))))))))) -- cgit v1.2.3