aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/world/file/watch.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/world/file/watch.lux')
-rw-r--r--stdlib/source/library/lux/world/file/watch.lux92
1 files changed, 46 insertions, 46 deletions
diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux
index 0e5deec4a..1625f79ef 100644
--- a/stdlib/source/library/lux/world/file/watch.lux
+++ b/stdlib/source/library/lux/world/file/watch.lux
@@ -20,7 +20,7 @@
["%" format (#+ format)]]
[collection
["." dictionary (#+ Dictionary)]
- ["." list ("#\." functor monoid fold)]
+ ["." list ("#\." functor monoid mix)]
["." set]
["." array]]]
[math
@@ -35,43 +35,43 @@
(abstract: .public Concern
{#.doc (example "A particular concern to watch-out for.")}
- {#create Bit
- #modify Bit
- #delete Bit}
+ {#creation Bit
+ #modification Bit
+ #deletion Bit}
(def: none
Concern
(:abstraction
- {#create false
- #modify false
- #delete false}))
+ {#creation false
+ #modification false
+ #deletion false}))
(template [<concern> <predicate> <event> <create> <modify> <delete>]
[(def: .public <concern>
Concern
(:abstraction
- {#create <create>
- #modify <modify>
- #delete <delete>}))
+ {#creation <create>
+ #modification <modify>
+ #deletion <delete>}))
(def: .public <predicate>
(Predicate Concern)
(|>> :representation (value@ <event>)))]
- [creation creation? #create
+ [creation creation? #creation
true false false]
- [modification modification? #modify
+ [modification modification? #modification
false true false]
- [deletion deletion? #delete
+ [deletion deletion? #deletion
false false true]
)
(def: .public (also left right)
(-> Concern Concern Concern)
(:abstraction
- {#create (or (..creation? left) (..creation? right))
- #modify (or (..modification? left) (..modification? right))
- #delete (or (..deletion? left) (..deletion? right))}))
+ {#creation (or (..creation? left) (..creation? right))
+ #modification (or (..modification? left) (..modification? right))
+ #deletion (or (..deletion? left) (..deletion? right))}))
(def: .public all
Concern
@@ -126,14 +126,14 @@
(-> (//.System Async) //.Path (Async (Try File_Tracker)))
(do {! (try.with async.monad)}
[files (\ fs directory_files directory)]
- (monad.fold !
- (function (_ file tracker)
- (do !
- [last_modified (\ fs last_modified file)]
- (in (dictionary.has file last_modified tracker))))
- (: File_Tracker
- (dictionary.empty text.hash))
- files)))
+ (monad.mix !
+ (function (_ file tracker)
+ (do !
+ [last_modified (\ fs last_modified file)]
+ (in (dictionary.has file last_modified tracker))))
+ (: File_Tracker
+ (dictionary.empty text.hash))
+ files)))
(def: (available_files fs directory)
(-> (//.System Async) //.Path (Async (Try (List [//.Path Instant]))))
@@ -172,15 +172,15 @@
current_files)]]
(in [[directory
[concern
- (let [with_deletions (list\fold dictionary.lacks file_tracker deletions)
- with_creations (list\fold (function (_ [path last_modified] tracker)
- (dictionary.has path last_modified tracker))
- with_deletions
- creations)
- with_modifications (list\fold (function (_ [path previous_modification current_modification] tracker)
- (dictionary.has path current_modification tracker))
- with_creations
- modifications)]
+ (let [with_deletions (list\mix dictionary.lacks file_tracker deletions)
+ with_creations (list\mix (function (_ [path last_modified] tracker)
+ (dictionary.has path last_modified tracker))
+ with_deletions
+ creations)
+ with_modifications (list\mix (function (_ [path previous_modification current_modification] tracker)
+ (dictionary.has path current_modification tracker))
+ with_creations
+ modifications)]
with_modifications)]]
[creations
modifications
@@ -243,13 +243,13 @@
tracker))]
(in (#try.Success [])))
.let [[creations modifications deletions]
- (list\fold (function (_ [_ [creations modifications deletions]]
- [all_creations all_modifications all_deletions])
- [(list\compose creations all_creations)
- (list\compose modifications all_modifications)
- (list\compose deletions all_deletions)])
- [(list) (list) (list)]
- changes)]]
+ (list\mix (function (_ [_ [creations modifications deletions]]
+ [all_creations all_modifications all_deletions])
+ [(list\compose creations all_creations)
+ (list\compose modifications all_modifications)
+ (list\compose deletions all_deletions)])
+ [(list) (list) (list)]
+ changes)]]
(in ($_ list\compose
(list\map (|>> product.left [..creation]) creations)
(|> modifications
@@ -340,7 +340,7 @@
(|>> java/nio/file/WatchKey::pollEvents
(\ io.monad map (|>> ..default_list
(list\map default_event_concern)
- (list\fold ..also ..none)))))
+ (list\mix ..also ..none)))))
(import: java/nio/file/WatchService
["#::."
@@ -364,11 +364,11 @@
(def: (default_start watch_events watcher path)
(-> (List Watch_Event) java/nio/file/WatchService //.Path (Async (Try java/nio/file/WatchKey)))
- (let [watch_events' (list\fold (function (_ [index watch_event] watch_events')
- (ffi.write! index watch_event watch_events'))
- (ffi.array (java/nio/file/WatchEvent$Kind java/lang/Object)
- (list.size watch_events))
- (list.enumeration watch_events))]
+ (let [watch_events' (list\mix (function (_ [index watch_event] watch_events')
+ (ffi.write! index watch_event watch_events'))
+ (ffi.array (java/nio/file/WatchEvent$Kind java/lang/Object)
+ (list.size watch_events))
+ (list.enumeration watch_events))]
(async.future
(java/nio/file/Path::register watcher
watch_events'