on master help sign in
Rename Toggle to Switch
commite715edcbff0a355f59a54d080bcc3050f18f5143 authorRanjeet Kumar Ranjan <ranjeetr@composewell.com> dateFri 26 Nov 2021, 14:08 (5 years ago) parent2bde24e
3 files changed+42−44
src/Streamly/Internal/FileSystem/Event/Darwin.hs+8−8 src/Streamly/Internal/FileSystem/Event/Linux.hs+23−25 src/Streamly/Internal/FileSystem/Event/Windows.hs+11−11
src/Streamly/Internal/FileSystem/Event/Darwin.hs+8−8
@@ -92,7 +92,7 @@ module Streamly.Internal.FileSystem.Event.Darwin
9292
9393 -- ** Default configuration
9494 Config (..)
95− , Toggle (..)
95+ , Switch (..)
9696 , defaultConfig
9797
9898 -- ** Watch Behavior
@@ -247,9 +247,9 @@ setEventBatching batchInfo cfg =
247247--
248248-- /Pre-release/
249249--
250−data Toggle = On | Off
250+data Switch = On | Off
251251
252−setFlag :: Word32 -> Toggle -> Config -> Config
252+setFlag :: Word32 -> Switch -> Config -> Config
253253setFlag mask status cfg@Config{..} =
254254 let flags =
255255 case status of
@@ -279,7 +279,7 @@ foreign import ccall safe
279279--
280280-- /Pre-release/
281281--
282−setRootPathEvents :: Toggle -> Config -> Config
282+setRootPathEvents :: Switch -> Config -> Config
283283setRootPathEvents = setFlag kFSEventStreamCreateFlagWatchRoot
284284
285285foreign import ccall safe
@@ -304,7 +304,7 @@ foreign import ccall safe
304304--
305305-- /Pre-release/
306306--
307−setFileEvents :: Toggle -> Config -> Config
307+setFileEvents :: Switch -> Config -> Config
308308setFileEvents = setFlag kFSEventStreamCreateFlagFileEvents
309309
310310foreign import ccall safe
@@ -320,7 +320,7 @@ foreign import ccall safe
320320--
321321-- /Pre-release/
322322--
323−setIgnoreSelf :: Toggle -> Config -> Config
323+setIgnoreSelf :: Switch -> Config -> Config
324324setIgnoreSelf = setFlag kFSEventStreamCreateFlagIgnoreSelf
325325
326326#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
@@ -336,7 +336,7 @@ foreign import ccall safe
336336--
337337-- /Pre-release/
338338--
339−setFullHistory :: Toggle -> Config -> Config
339+setFullHistory :: Switch -> Config -> Config
340340setFullHistory = setFlag kFSEventStreamCreateFlagFullHistory
341341#endif
342342
@@ -347,7 +347,7 @@ setFullHistory = setFlag kFSEventStreamCreateFlagFullHistory
347347--
348348-- /Pre-release/
349349--
350−setAllEvents :: Toggle -> Config -> Config
350+setAllEvents :: Switch -> Config -> Config
351351setAllEvents s =
352352 setRootPathEvents s
353353 . setFileEvents s
src/Streamly/Internal/FileSystem/Event/Linux.hs+23−25
@@ -64,7 +64,7 @@ module Streamly.Internal.FileSystem.Event.Linux
6464
6565 -- ** Default configuration
6666 Config (..)
67− , Toggle (..)
67+ , Switch (..)
6868 , defaultConfig
6969
7070 -- ** Watch Behavior
@@ -215,19 +215,17 @@ data Config = Config
215215-- Boolean settings
216216-------------------------------------------------------------------------------
217217
218−-- XXX Change Toggle to "OnOff" or "Switch". The name Toggle may be confusing.
219−--
220218-- | Whether a setting is 'On' or 'Off'.
221219--
222220-- /Pre-release/
223221--
224−data Toggle = On | Off deriving (Show, Eq)
222+data Switch = On | Off deriving (Show, Eq)
225223
226−toggle :: Toggle -> Toggle
224+toggle :: Switch -> Switch
227225toggle On = Off
228226toggle Off = On
229227
230−setFlag :: Word32 -> Toggle -> Config -> Config
228+setFlag :: Word32 -> Switch -> Config -> Config
231229setFlag mask status cfg@Config{..} =
232230 let flags =
233231 case status of
@@ -246,7 +244,7 @@ setFlag mask status cfg@Config{..} =
246244--
247245-- /Pre-release/
248246--
249−setRecursiveMode :: Toggle -> Config -> Config
247+setRecursiveMode :: Switch -> Config -> Config
250248setRecursiveMode rec cfg@Config{} = cfg {watchRec = rec == On}
251249
252250foreign import capi
@@ -262,7 +260,7 @@ foreign import capi
262260--
263261-- /Pre-release/
264262--
265−setFollowSymLinks :: Toggle -> Config -> Config
263+setFollowSymLinks :: Switch -> Config -> Config
266264setFollowSymLinks s = setFlag iN_DONT_FOLLOW (toggle s)
267265
268266foreign import capi
@@ -275,7 +273,7 @@ foreign import capi
275273--
276274-- /Pre-release/
277275--
278−setUnwatchMoved :: Toggle -> Config -> Config
276+setUnwatchMoved :: Switch -> Config -> Config
279277setUnwatchMoved = setFlag iN_EXCL_UNLINK
280278
281279#if HAVE_DECL_IN_MASK_CREATE
@@ -323,7 +321,7 @@ foreign import capi
323321--
324322-- /Pre-release/
325323--
326−setOneShot :: Toggle -> Config -> Config
324+setOneShot :: Switch -> Config -> Config
327325setOneShot = setFlag iN_ONESHOT
328326
329327foreign import capi
@@ -336,7 +334,7 @@ foreign import capi
336334--
337335-- /Pre-release/
338336--
339−setOnlyDir :: Toggle -> Config -> Config
337+setOnlyDir :: Switch -> Config -> Config
340338setOnlyDir = setFlag iN_ONLYDIR
341339
342340-------------------------------------------------------------------------------
@@ -352,7 +350,7 @@ foreign import capi
352350--
353351-- /Pre-release/
354352--
355−setRootDeleted :: Toggle -> Config -> Config
353+setRootDeleted :: Switch -> Config -> Config
356354setRootDeleted = setFlag iN_DELETE_SELF
357355
358356foreign import capi
@@ -364,7 +362,7 @@ foreign import capi
364362--
365363-- /Pre-release/
366364--
367−setRootMoved :: Toggle -> Config -> Config
365+setRootMoved :: Switch -> Config -> Config
368366setRootMoved = setFlag iN_MOVE_SELF
369367
370368-- | Report when the watched root path itself gets deleted or renamed.
@@ -373,7 +371,7 @@ setRootMoved = setFlag iN_MOVE_SELF
373371--
374372-- /Pre-release/
375373--
376−setRootPathEvents :: Toggle -> Config -> Config
374+setRootPathEvents :: Switch -> Config -> Config
377375setRootPathEvents = setFlag (iN_DELETE_SELF .|. iN_MOVE_SELF)
378376
379377foreign import capi
@@ -386,7 +384,7 @@ foreign import capi
386384--
387385-- /Pre-release/
388386--
389−setAttrsModified :: Toggle -> Config -> Config
387+setAttrsModified :: Switch -> Config -> Config
390388setAttrsModified = setFlag iN_ATTRIB
391389
392390foreign import capi
@@ -398,7 +396,7 @@ foreign import capi
398396--
399397-- /Pre-release/
400398--
401−setAccessed :: Toggle -> Config -> Config
399+setAccessed :: Switch -> Config -> Config
402400setAccessed = setFlag iN_ACCESS
403401
404402foreign import capi
@@ -410,7 +408,7 @@ foreign import capi
410408--
411409-- /Pre-release/
412410--
413−setOpened :: Toggle -> Config -> Config
411+setOpened :: Switch -> Config -> Config
414412setOpened = setFlag iN_OPEN
415413
416414foreign import capi
@@ -422,7 +420,7 @@ foreign import capi
422420--
423421-- /Pre-release/
424422--
425−setWriteClosed :: Toggle -> Config -> Config
423+setWriteClosed :: Switch -> Config -> Config
426424setWriteClosed = setFlag iN_CLOSE_WRITE
427425
428426foreign import capi
@@ -434,7 +432,7 @@ foreign import capi
434432--
435433-- /Pre-release/
436434--
437−setNonWriteClosed :: Toggle -> Config -> Config
435+setNonWriteClosed :: Switch -> Config -> Config
438436setNonWriteClosed = setFlag iN_CLOSE_NOWRITE
439437
440438foreign import capi
@@ -446,7 +444,7 @@ foreign import capi
446444--
447445-- /Pre-release/
448446--
449−setCreated :: Toggle -> Config -> Config
447+setCreated :: Switch -> Config -> Config
450448setCreated = setFlag iN_CREATE
451449
452450foreign import capi
@@ -458,7 +456,7 @@ foreign import capi
458456--
459457-- /Pre-release/
460458--
461−setDeleted :: Toggle -> Config -> Config
459+setDeleted :: Switch -> Config -> Config
462460setDeleted = setFlag iN_DELETE
463461
464462foreign import capi
@@ -470,7 +468,7 @@ foreign import capi
470468--
471469-- /Pre-release/
472470--
473−setMovedFrom :: Toggle -> Config -> Config
471+setMovedFrom :: Switch -> Config -> Config
474472setMovedFrom = setFlag iN_MOVED_FROM
475473
476474foreign import capi
@@ -482,7 +480,7 @@ foreign import capi
482480--
483481-- /Pre-release/
484482--
485−setMovedTo :: Toggle -> Config -> Config
483+setMovedTo :: Switch -> Config -> Config
486484setMovedTo = setFlag iN_MOVED_TO
487485
488486foreign import capi
@@ -494,7 +492,7 @@ foreign import capi
494492--
495493-- /Pre-release/
496494--
497−setModified :: Toggle -> Config -> Config
495+setModified :: Switch -> Config -> Config
498496setModified = setFlag iN_MODIFY
499497
500498-- | Set all tunable events 'On' or 'Off'. Equivalent to setting:
@@ -514,7 +512,7 @@ setModified = setFlag iN_MODIFY
514512--
515513-- /Pre-release/
516514--
517−setAllEvents :: Toggle -> Config -> Config
515+setAllEvents :: Switch -> Config -> Config
518516setAllEvents s =
519517 setRootDeleted s
520518 . setRootMoved s
src/Streamly/Internal/FileSystem/Event/Windows.hs+11−11
@@ -48,7 +48,7 @@ module Streamly.Internal.FileSystem.Event.Windows
4848
4949 -- ** Default configuration
5050 Config
51− , Toggle (..)
51+ , Switch (..)
5252 , defaultConfig
5353
5454 -- ** Watch Behavior
@@ -143,9 +143,9 @@ data Config = Config
143143--
144144-- /Pre-release/
145145--
146−data Toggle = On | Off deriving (Show, Eq)
146+data Switch = On | Off deriving (Show, Eq)
147147
148−setFlag :: DWORD -> Toggle -> Config -> Config
148+setFlag :: DWORD -> Switch -> Config -> Config
149149setFlag mask status cfg@Config{..} =
150150 let flags =
151151 case status of
@@ -159,7 +159,7 @@ setFlag mask status cfg@Config{..} =
159159--
160160-- /Pre-release/
161161--
162−setRecursiveMode :: Toggle -> Config -> Config
162+setRecursiveMode :: Switch -> Config -> Config
163163setRecursiveMode rec cfg@Config{} = cfg {watchRec = rec == On}
164164
165165-- | Generate notify events on file create, rename or delete.
@@ -172,7 +172,7 @@ setRecursiveMode rec cfg@Config{} = cfg {watchRec = rec == On}
172172--
173173-- /Pre-release/
174174--
175−setFileNameEvents :: Toggle -> Config -> Config
175+setFileNameEvents :: Switch -> Config -> Config
176176setFileNameEvents = setFlag fILE_NOTIFY_CHANGE_FILE_NAME
177177
178178-- | Generate notify events on directory create, rename or delete.
@@ -185,7 +185,7 @@ setFileNameEvents = setFlag fILE_NOTIFY_CHANGE_FILE_NAME
185185--
186186-- /Pre-release/
187187--
188−setDirNameEvents :: Toggle -> Config -> Config
188+setDirNameEvents :: Switch -> Config -> Config
189189setDirNameEvents = setFlag fILE_NOTIFY_CHANGE_DIR_NAME
190190
191191-- | Generate an 'isModified' event on any attribute change in the watched
@@ -195,7 +195,7 @@ setDirNameEvents = setFlag fILE_NOTIFY_CHANGE_DIR_NAME
195195--
196196-- /Pre-release/
197197--
198−setAttrsModified :: Toggle -> Config -> Config
198+setAttrsModified :: Switch -> Config -> Config
199199setAttrsModified = setFlag fILE_NOTIFY_CHANGE_ATTRIBUTES
200200
201201-- | Generate an 'isModified' event when the file size is changed.
@@ -210,7 +210,7 @@ setAttrsModified = setFlag fILE_NOTIFY_CHANGE_ATTRIBUTES
210210--
211211-- /Pre-release/
212212--
213−setSizeModified :: Toggle -> Config -> Config
213+setSizeModified :: Switch -> Config -> Config
214214setSizeModified = setFlag fILE_NOTIFY_CHANGE_SIZE
215215
216216-- | Generate an 'isModified' event when the last write timestamp of the file
@@ -227,7 +227,7 @@ setSizeModified = setFlag fILE_NOTIFY_CHANGE_SIZE
227227--
228228-- /Pre-release/
229229--
230−setLastWriteTimeModified :: Toggle -> Config -> Config
230+setLastWriteTimeModified :: Switch -> Config -> Config
231231setLastWriteTimeModified = setFlag fILE_NOTIFY_CHANGE_LAST_WRITE
232232
233233-- | Generate an 'isModified' event when any security-descriptor change occurs
@@ -237,7 +237,7 @@ setLastWriteTimeModified = setFlag fILE_NOTIFY_CHANGE_LAST_WRITE
237237--
238238-- /Pre-release/
239239--
240−setSecurityModified :: Toggle -> Config -> Config
240+setSecurityModified :: Switch -> Config -> Config
241241setSecurityModified = setFlag fILE_NOTIFY_CHANGE_SECURITY
242242
243243-- | Set all tunable events 'On' or 'Off'. Equivalent to setting:
@@ -251,7 +251,7 @@ setSecurityModified = setFlag fILE_NOTIFY_CHANGE_SECURITY
251251--
252252-- /Pre-release/
253253--
254−setAllEvents :: Toggle -> Config -> Config
254+setAllEvents :: Switch -> Config -> Config
255255setAllEvents s =
256256 setFileNameEvents s
257257 . setDirNameEvents s