@@ -431,7 +431,7 @@ getCurrentYear = do
431
431
-- | From System.Directory.Extra
432
432
-- https://hackage.haskell.org/package/extra-1.7.9
433
433
listFilesInside :: (FilePath -> IO Bool ) -> FilePath -> IO [FilePath ]
434
- listFilesInside test dir = ifM (notM $ test $ dropTrailingPathSeparator dir) (pure [] ) $ do
434
+ listFilesInside test dir = ifNotM ( test $ dropTrailingPathSeparator dir) (pure [] ) $ do
435
435
(dirs,files) <- partitionM doesDirectoryExist =<< listContents dir
436
436
rest <- concatMapM (listFilesInside test) dirs
437
437
pure $ files ++ rest
@@ -453,6 +453,11 @@ listContents dir = do
453
453
ifM :: Monad m => m Bool -> m a -> m a -> m a
454
454
ifM b t f = do b' <- b; if b' then t else f
455
455
456
+ -- | 'ifM' with swapped branches:
457
+ -- @ifNotM b t f = ifM (not <$> b) t f@
458
+ ifNotM :: Monad m => m Bool -> m a -> m a -> m a
459
+ ifNotM = flip . ifM
460
+
456
461
-- | From Control.Monad.Extra
457
462
-- https://hackage.haskell.org/package/extra-1.7.9
458
463
concatMapM :: Monad m => (a -> m [b ]) -> [a ] -> m [b ]
@@ -469,11 +474,6 @@ partitionM f (x:xs) = do
469
474
(as,bs) <- partitionM f xs
470
475
pure ([x | res]++ as, [x | not res]++ bs)
471
476
472
- -- | From Control.Monad.Extra
473
- -- https://hackage.haskell.org/package/extra-1.7.9
474
- notM :: Functor m => m Bool -> m Bool
475
- notM = fmap not
476
-
477
477
safeRead :: Read a => String -> Maybe a
478
478
safeRead s
479
479
| [(x, " " )] <- reads s = Just x
0 commit comments