@@ -92,7 +92,6 @@ module Streamly.Internal.FileSystem.Event.Darwin
9292
9393 -- ** Default configuration
9494 Config (..)
95− , Switch (..)
9695 , defaultConfig
9796
9897 -- ** Watch Behavior
@@ -192,7 +191,7 @@ import qualified Streamly.Internal.Data.Array.Unboxed as A
192191-------------------------------------------------------------------------------
193192
194193-- XXX Add a recursive option to Config
195−-- Keep setRecursiveMode Off as undefined for now until we implement it.
194+-- Keep setRecursiveMode False as undefined for now until we implement it.
196195--
197196-- | Watch configuration, used to specify the events of interest and the
198197-- behavior of the watch.
@@ -233,28 +232,22 @@ setEventBatching :: BatchInfo -> Config -> Config
233232setEventBatching batchInfo cfg =
234233 let (t, status) =
235234 case batchInfo of
236− Throttle sec | sec < 0 -> (0, On)
237− Throttle sec -> (sec, On)
238− Batch sec | sec < 0 -> (0, Off)
239− Batch sec -> (sec, Off)
235+ Throttle sec | sec < 0 -> (0, True)
236+ Throttle sec -> (sec, True)
237+ Batch sec | sec < 0 -> (0, False)
238+ Batch sec -> (sec, False)
240239 in setFlag kFSEventStreamCreateFlagNoDefer status $ cfg {latency = t}
241240
242241-------------------------------------------------------------------------------
243242-- Boolean settings
244243-------------------------------------------------------------------------------
245244
246−-- | Whether a setting is 'On' or 'Off'.
247−--
248−-- /Pre-release/
249−--
250−data Switch = On | Off
251−
252−setFlag :: Word32 -> Switch -> Config -> Config
245+setFlag :: Word32 -> Bool -> Config -> Config
253246setFlag mask status cfg@Config{..} =
254247 let flags =
255− case status of
256− On -> createFlags .|. mask
257− Off -> createFlags .&. complement mask
248+ if status
249+ then createFlags .|. mask
250+ else createFlags .&. complement mask
258251 in cfg {createFlags = flags}
259252
260253foreign import ccall safe
@@ -267,26 +260,26 @@ foreign import ccall safe
267260-- | Any changes to the path (delete, rename, or create) of an object are
268261-- reported as events for its parent directory. Such events are not reported
269262-- for the watch root itself because its parent is not being watched. When
270−-- 'setRootPathEvents' is 'On', an 'isRootPathEvent' event is generated with an
263+-- 'setRootPathEvents' is 'True', an 'isRootPathEvent' event is generated with an
271264-- eventId 0 if the watch root is deleted, renamed or created.
272265--
273266-- Note: We have observed that an 'isDeleted' event occurs for the root path
274267-- (when it is a regular dir and not symlink) even when this option is off.
275268--
276−-- /default: Off/
269+-- /default: False/
277270--
278271-- /macOS 10.5+/
279272--
280273-- /Pre-release/
281274--
282−setRootPathEvents :: Switch -> Config -> Config
275+setRootPathEvents :: Bool -> Config -> Config
283276setRootPathEvents = setFlag kFSEventStreamCreateFlagWatchRoot
284277
285278foreign import ccall safe
286279 "FSEventStreamCreateFlagFileEvents"
287280 kFSEventStreamCreateFlagFileEvents :: Word32
288281
289−-- | When this is 'Off' only events for the watched directories are reported.
282+-- | When this is 'False' only events for the watched directories are reported.
290283-- For example, when a file is created inside a directory it is reported as an
291284-- event, the path name in the event is the path of the directory being watched
292285-- and not of the specific item for which the event occurred. Events cannot be
@@ -294,33 +287,33 @@ foreign import ccall safe
294287-- if an event is a "create" or "delete", we only know that some event ocurred
295288-- under the watched directory hierarchy.
296289--
297−-- When it is 'On' the path reported in the event is the path of the item and
290+-- When it is 'True' the path reported in the event is the path of the item and
298291-- not the of the directory in which it is contained. We can use the event
299292-- accessor functions to determine the event type and the path type etc.
300293--
301−-- /default: On/
294+-- /default: True/
302295--
303296-- /macOS 10.7+/
304297--
305298-- /Pre-release/
306299--
307−setFileEvents :: Switch -> Config -> Config
300+setFileEvents :: Bool -> Config -> Config
308301setFileEvents = setFlag kFSEventStreamCreateFlagFileEvents
309302
310303foreign import ccall safe
311304 "FSEventStreamCreateFlagIgnoreSelf"
312305 kFSEventStreamCreateFlagIgnoreSelf :: Word32
313306
314−-- | When this is 'On' events generated by the current process are not
307+-- | When this is 'True' events generated by the current process are not
315308-- reported.
316309--
317−-- /default: Off/
310+-- /default: False/
318311--
319312-- /macOS 10.6+/
320313--
321314-- /Pre-release/
322315--
323−setIgnoreSelf :: Switch -> Config -> Config
316+setIgnoreSelf :: Bool -> Config -> Config
324317setIgnoreSelf = setFlag kFSEventStreamCreateFlagIgnoreSelf
325318
326319#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
@@ -328,26 +321,26 @@ foreign import ccall safe
328321 "FSEventStreamCreateFlagFullHistory"
329322 kFSEventStreamCreateFlagFullHistory :: Word32
330323
331−-- | When this is 'On' all events since the beginning of time are reported.
324+-- | When this is 'True' all events since the beginning of time are reported.
332325--
333−-- /default: Off/
326+-- /default: False/
334327--
335328-- /macOS 10.15+/
336329--
337330-- /Pre-release/
338331--
339−setFullHistory :: Switch -> Config -> Config
332+setFullHistory :: Bool -> Config -> Config
340333setFullHistory = setFlag kFSEventStreamCreateFlagFullHistory
341334#endif
342335
343−-- | Set all tunable events 'On' or 'Off'. Equivalent to setting:
336+-- | Set all tunable events 'True' or 'False'. Equivalent to setting:
344337--
345338-- * setRootPathEvents
346339-- * setFileEvents
347340--
348341-- /Pre-release/
349342--
350−setAllEvents :: Switch -> Config -> Config
343+setAllEvents :: Bool -> Config -> Config
351344setAllEvents s =
352345 setRootPathEvents s
353346 . setFileEvents s
@@ -359,17 +352,17 @@ setAllEvents s =
359352-- | The default settings are:
360353--
361354-- * 'setEventBatching' ('Batch' 0.0)
362−-- * 'setFileEvents' 'On'
363−-- * 'setRootPathEvents' 'Off'
364−-- * 'setIgnoreSelf' 'Off'
355+-- * 'setFileEvents' 'True'
356+-- * 'setRootPathEvents' 'False'
357+-- * 'setIgnoreSelf' 'False'
365358#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
366−-- * 'setFullHistory' 'Off'
359+-- * 'setFullHistory' 'False'
367360#endif
368361--
369362-- /Pre-release/
370363--
371364defaultConfig :: Config
372−defaultConfig = setFileEvents On $ Config
365+defaultConfig = setFileEvents True $ Config
373366 { latency = 0.0
374367 , createFlags = 0
375368 }
@@ -559,7 +552,7 @@ watchToStream (Watch handle _ _) =
559552-- @
560553-- {-\# LANGUAGE MagicHash #-}
561554-- watchWith
562−-- ('setIgnoreSelf' 'On' . 'setRootPathEvents' 'On')
555+-- ('setIgnoreSelf' 'True' . 'setRootPathEvents' 'True')
563556-- [Array.fromList "path"]
564557-- @
565558--
@@ -719,7 +712,7 @@ foreign import ccall safe
719712-- object itself. Note that the object may become unreachable or deleted after
720713-- a change of path.
721714--
722−-- /Applicable only when 'setRootPathEvents' is 'On'/
715+-- /Applicable only when 'setRootPathEvents' is 'True'/
723716--
724717-- /Occurs only for the watched path/
725718--
@@ -763,7 +756,7 @@ isUnmounted :: Event -> Bool
763756isUnmounted = getFlag kFSEventStreamEventFlagUnmount
764757
765758-------------------------------------------------------------------------------
766−-- Metadata change Events (applicable only when 'setFileEvents' is 'On')
759+-- Metadata change Events (applicable only when 'setFileEvents' is 'True')
767760-------------------------------------------------------------------------------
768761
769762foreign import ccall safe
@@ -776,7 +769,7 @@ foreign import ccall safe
776769-- Note that this event may be generated even if the metadata is changed to the
777770-- same value again.
778771--
779−-- /Applicable only when 'setFileEvents' is 'On'/
772+-- /Applicable only when 'setFileEvents' is 'True'/
780773--
781774-- /Can occur for watched path or a file inside it/
782775--
@@ -797,7 +790,7 @@ foreign import ccall safe
797790-- modification time. It does not occur when the link count of a file changes
798791-- (as of macOS 10.15.1).
799792--
800−-- /Applicable only when 'setFileEvents' is 'On'/
793+-- /Applicable only when 'setFileEvents' is 'True'/
801794--
802795-- /Can occur for watched path or a file inside it/
803796--
@@ -815,7 +808,7 @@ foreign import ccall safe
815808-- | Determine whether the event indicates finder information metadata change
816809-- for an object contained within the monitored path.
817810--
818−-- /Applicable only when 'setFileEvents' is 'On'/
811+-- /Applicable only when 'setFileEvents' is 'True'/
819812--
820813-- /macOS 10.7+/
821814--
@@ -831,7 +824,7 @@ foreign import ccall safe
831824-- | Determine whether the event indicates extended attributes metadata change
832825-- for an object contained within the monitored path.
833826--
834−-- /Applicable only when 'setFileEvents' is 'On'/
827+-- /Applicable only when 'setFileEvents' is 'True'/
835828--
836829-- /Can occur for watched path or a file inside it/
837830--
@@ -843,7 +836,7 @@ isXAttrsModified :: Event -> Bool
843836isXAttrsModified = getFlag kFSEventStreamEventFlagItemXattrMod
844837
845838-------------------------------------------------------------------------------
846−-- CRUD Events (applicable only when 'setFileEvents' is 'On')
839+-- CRUD Events (applicable only when 'setFileEvents' is 'True')
847840-------------------------------------------------------------------------------
848841
849842foreign import ccall safe
@@ -865,7 +858,7 @@ foreign import ccall safe
865858-- only an 'isAttrsModified' event occurs and there is no 'isCreated'
866859-- event. However, this seems to have been fixed on 10.15.6.
867860--
868−-- /Applicable only when 'setFileEvents' is 'On'/
861+-- /Applicable only when 'setFileEvents' is 'True'/
869862--
870863-- /Can occur for watched path or a file inside it/
871864--
@@ -883,7 +876,7 @@ foreign import ccall safe
883876-- | Determine whether the event indicates deletion of an object within the
884877-- monitored path. This is true when a file or a hardlink is deleted.
885878--
886−-- Applicable only when 'setFileEvents' is 'On'.
879+-- Applicable only when 'setFileEvents' is 'True'.
887880--
888881-- /Can occur for watched path or a file inside it/
889882--
@@ -902,7 +895,7 @@ foreign import ccall safe
902895-- monitored path. This event is generated when a file is renamed within the
903896-- watched directory or if it is moved out of or in the watched directory.
904897--
905−-- /Applicable only when 'setFileEvents' is 'On'/
898+-- /Applicable only when 'setFileEvents' is 'True'/
906899--
907900-- /Can occur for watched path or a file inside it/
908901--
@@ -920,7 +913,7 @@ foreign import ccall safe
920913-- | Determine whether the event indicates modification of an object within the
921914-- monitored path. This event is generated only for files and not directories.
922915--
923−-- Applicable only when 'setFileEvents' is 'On'.
916+-- Applicable only when 'setFileEvents' is 'True'.
924917--
925918-- /macOS 10.7+/
926919--
@@ -938,7 +931,7 @@ foreign import ccall safe
938931-- monitored path. The "Duplicate" command in the "File" menu of the "Finder"
939932-- application generates a "clone" event.
940933--
941−-- Applicable only when 'setFileEvents' is 'On'.
934+-- Applicable only when 'setFileEvents' is 'True'.
942935--
943936-- /macOS 10.13+/
944937--
@@ -949,7 +942,7 @@ isCloned = getFlag kFSEventStreamEventFlagItemCloned
949942#endif
950943
951944-------------------------------------------------------------------------------
952−-- Information about path type (applicable only when 'setFileEvents' is 'On')
945+-- Information about path type (applicable only when 'setFileEvents' is 'True')
953946-------------------------------------------------------------------------------
954947
955948foreign import ccall safe
@@ -958,7 +951,7 @@ foreign import ccall safe
958951
959952-- | Determine whether the event is for a directory path.
960953--
961−-- Applicable only when 'setFileEvents' is 'On'.
954+-- Applicable only when 'setFileEvents' is 'True'.
962955--
963956-- /macOS 10.7+/
964957--
@@ -973,7 +966,7 @@ foreign import ccall safe
973966
974967-- | Determine whether the event is for a file path.
975968--
976−-- Applicable only when 'setFileEvents' is 'On'.
969+-- Applicable only when 'setFileEvents' is 'True'.
977970--
978971-- /macOS 10.7+/
979972--
@@ -988,7 +981,7 @@ foreign import ccall safe
988981
989982-- | Determine whether the event is for a symbolic link path.
990983--
991−-- Applicable only when 'setFileEvents' is 'On'.
984+-- Applicable only when 'setFileEvents' is 'True'.
992985--
993986-- /macOS 10.7+/
994987--
@@ -1008,7 +1001,7 @@ foreign import ccall safe
10081001-- which has or had more than one link in the past is removed. This is not true
10091002-- if a file never had more than one link.
10101003--
1011−-- Applicable only when 'setFileEvents' is 'On'.
1004+-- Applicable only when 'setFileEvents' is 'True'.
10121005--
10131006-- /macOS 10.10+/
10141007--
@@ -1026,7 +1019,7 @@ foreign import ccall safe
10261019-- is true when a file has had more than one link and now the last link is
10271020-- removed. In that case both 'isHardLink' and 'isLastHardLink" would be true.
10281021--
1029−-- Applicable only when 'setFileEvents' is 'On'.
1022+-- Applicable only when 'setFileEvents' is 'True'.
10301023--
10311024-- /macOS 10.10+/
10321025--