Hello community, here is the log from the commit of package ghc-extra for openSUSE:Factory checked in at 2018-07-24 17:18:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-extra (Old) and /work/SRC/openSUSE:Factory/.ghc-extra.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-extra" Tue Jul 24 17:18:32 2018 rev:17 rq:623768 version:1.6.9 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-extra/ghc-extra.changes 2018-05-30 12:25:37.937684616 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-extra.new/ghc-extra.changes 2018-07-24 17:18:36.451009111 +0200 @@ -1,0 +2,25 @@ +Wed Jul 18 14:26:23 UTC 2018 - [email protected] + +- Cosmetic: replace tabs with blanks, strip trailing white space, + and update copyright headers with spec-cleaner. + +------------------------------------------------------------------- +Tue Jul 17 19:31:05 UTC 2018 - [email protected] + +- Update extra to version 1.6.9. + 1.6.9, released 2018-07-12 + Add loop, the non-monadic version of loopM + #36, add whenMaybe and whenMaybeM + +------------------------------------------------------------------- +Fri Jul 13 14:31:51 UTC 2018 - [email protected] + +- Update extra to version 1.6.8. + 1.6.8, released 2018-05-24 + Add notNull + Add listDirectories + 1.6.7, released 2018-05-23 + #35, add fold1M and fold1M_ + #34, lots of documentation typos + +------------------------------------------------------------------- @@ -128 +152,0 @@ - Old: ---- extra-1.6.6.tar.gz New: ---- extra-1.6.9.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-extra.spec ++++++ --- /var/tmp/diff_new_pack.dv34dO/_old 2018-07-24 17:18:36.883009667 +0200 +++ /var/tmp/diff_new_pack.dv34dO/_new 2018-07-24 17:18:36.887009672 +0200 @@ -19,7 +19,7 @@ %global pkg_name extra %bcond_with tests Name: ghc-%{pkg_name} -Version: 1.6.6 +Version: 1.6.9 Release: 0 Summary: Extra functions I use License: BSD-3-Clause ++++++ extra-1.6.6.tar.gz -> extra-1.6.9.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/extra-1.6.6/CHANGES.txt new/extra-1.6.9/CHANGES.txt --- old/extra-1.6.6/CHANGES.txt 2018-04-16 22:51:31.000000000 +0200 +++ new/extra-1.6.9/CHANGES.txt 2018-07-12 23:36:55.000000000 +0200 @@ -1,5 +1,14 @@ Changelog for Extra +1.6.9, released 2018-07-12 + Add loop, the non-monadic version of loopM + #36, add whenMaybe and whenMaybeM +1.6.8, released 2018-05-24 + Add notNull + Add listDirectories +1.6.7, released 2018-05-23 + #35, add fold1M and fold1M_ + #34, lots of documentation typos 1.6.6, released 2018-04-16 Add escapeJSON and unescapeJSON Add escapeHTML and unescapeHTML diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/extra-1.6.6/README.md new/extra-1.6.9/README.md --- old/extra-1.6.6/README.md 2018-04-16 22:51:31.000000000 +0200 +++ new/extra-1.6.9/README.md 2018-07-12 23:36:55.000000000 +0200 @@ -1,4 +1,4 @@ -# Extra [](https://hackage.haskell.org/package/extra) [](https://www.stackage.org/package/extra) [](https://travis-ci.org/ndmitchell/extra) [](https://ci.appveyor.com/project/ndmitchell/extra) +# Extra [](https://hackage.haskell.org/package/extra) [](https://www.stackage.org/package/extra) [](https://travis-ci.org/ndmitchell/extra) [](https://ci.appveyor.com/project/ndmitchell/extra) A library of extra functions for the standard Haskell libraries. Most functions are simple additions, filling out missing functionality. A few functions are available in later versions of GHC, but this package makes them available back to GHC 7.2. A few examples: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/extra-1.6.6/extra.cabal new/extra-1.6.9/extra.cabal --- old/extra-1.6.6/extra.cabal 2018-04-16 22:51:31.000000000 +0200 +++ new/extra-1.6.9/extra.cabal 2018-07-12 23:36:55.000000000 +0200 @@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: extra -version: 1.6.6 +version: 1.6.9 license: BSD3 license-file: LICENSE category: Development @@ -15,7 +15,7 @@ The module "Extra" documents all functions provided by this library. Modules such as "Data.List.Extra" provide extra functions over "Data.List" and also reexport "Data.List". Users are recommended to replace "Data.List" imports with "Data.List.Extra" if they need the extra functionality. homepage: https://github.com/ndmitchell/extra#readme bug-reports: https://github.com/ndmitchell/extra/issues -tested-with: GHC==8.4.1, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2 +tested-with: GHC==8.4.3, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2 extra-doc-files: CHANGES.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/extra-1.6.6/src/Control/Concurrent/Extra.hs new/extra-1.6.9/src/Control/Concurrent/Extra.hs --- old/extra-1.6.6/src/Control/Concurrent/Extra.hs 2018-04-16 22:51:31.000000000 +0200 +++ new/extra-1.6.9/src/Control/Concurrent/Extra.hs 2018-07-12 23:36:55.000000000 +0200 @@ -62,7 +62,7 @@ -- called with asynchronous exceptions masked. -- -- @ --- forkFinally action and_then = +-- 'forkFinally' action and_then = -- mask $ \restore -> -- forkIO $ try (restore action) >>= and_then -- @ @@ -116,8 +116,8 @@ --------------------------------------------------------------------- -- LOCK --- | Like an MVar, but has no value. --- Used to guarantees single-threaded access, typically to some system resource. +-- | Like an 'MVar', but has no value. +-- Used to guarantee single-threaded access, typically to some system resource. -- As an example: -- -- @ @@ -128,7 +128,7 @@ -- @ -- -- Here we are creating a lock to ensure that when writing output our messages --- do not get interleaved. This use of MVar never blocks on a put. It is permissible, +-- do not get interleaved. This use of 'MVar' never blocks on a put. It is permissible, -- but rare, that a withLock contains a withLock inside it - but if so, -- watch out for deadlocks. @@ -155,23 +155,23 @@ --------------------------------------------------------------------- -- VAR --- | Like an MVar, but must always be full. --- Used to on a mutable variable in a thread-safe way. +-- | Like an 'MVar', but must always be full. +-- Used to operate on a mutable variable in a thread-safe way. -- As an example: -- -- @ -- hits <- 'newVar' 0 -- forkIO $ do ...; 'modifyVar_' hits (+1); ... -- i <- 'readVar' hits --- print ("HITS",i) +-- print (\"HITS\",i) -- @ -- -- Here we have a variable which we modify atomically, so modifications are --- not interleaved. This use of MVar never blocks on a put. No modifyVar +-- not interleaved. This use of 'MVar' never blocks on a put. No modifyVar -- operation should ever block, and they should always complete in a reasonable --- timeframe. A Var should not be used to protect some external resource, only --- the variable contained within. Information from a readVar should not be subsequently --- inserted back into the Var. +-- timeframe. A 'Var' should not be used to protect some external resource, only +-- the variable contained within. Information from a 'readVar' should not be subsequently +-- inserted back into the 'Var'. newtype Var a = Var (MVar a) -- | Create a new 'Var' with a value. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/extra-1.6.6/src/Control/Monad/Extra.hs new/extra-1.6.9/src/Control/Monad/Extra.hs --- old/extra-1.6.6/src/Control/Monad/Extra.hs 2018-04-16 22:51:31.000000000 +0200 +++ new/extra-1.6.9/src/Control/Monad/Extra.hs 2018-07-12 23:36:55.000000000 +0200 @@ -1,22 +1,26 @@ +{-# LANGUAGE ConstraintKinds #-} -- | Extra functions for "Control.Monad". -- These functions provide looping, list operations and booleans. --- If you need a wider selection of monad loops and list generalisations, --- see <http://hackage.haskell.org/package/monad-loops monad-loops>. +-- If you need a wider selection of monad loops and list generalisations, +-- see <http://hackage.haskell.org/package/monad-loops monad-loops>. module Control.Monad.Extra( module Control.Monad, whenJust, whenJustM, + whenMaybe, whenMaybeM, unit, maybeM, eitherM, -- * Loops - loopM, whileM, + loop, loopM, whileM, -- * Lists partitionM, concatMapM, concatForM, mconcatMapM, mapMaybeM, findM, firstJustM, + fold1M, fold1M_, -- * Booleans whenM, unlessM, ifM, notM, (||^), (&&^), orM, andM, anyM, allM ) where import Control.Monad +import Control.Exception.Extra import Data.Maybe import Control.Applicative import Data.Monoid @@ -33,8 +37,26 @@ -- | Like 'whenJust', but where the test can be monadic. whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m () +-- Can't reuse whenMaybe on GHC 7.8 or lower because Monad does not imply Applicative whenJustM mg f = maybe (return ()) f =<< mg + +-- | Like 'when', but return either 'Nothing' if the predicate was 'False', +-- of 'Just' with the result of the computation. +-- +-- > whenMaybe True (print 1) == fmap Just (print 1) +-- > whenMaybe False (print 1) == return Nothing +whenMaybe :: Applicative m => Bool -> m a -> m (Maybe a) +whenMaybe b x = if b then Just <$> x else pure Nothing + +-- | Like 'whenMaybe', but where the test can be monadic. +whenMaybeM :: Monad m => m Bool -> m a -> m (Maybe a) +-- Can't reuse whenMaybe on GHC 7.8 or lower because Monad does not imply Applicative +whenMaybeM mb x = do + b <- mb + if b then liftM Just x else return Nothing + + -- | The identity function which requires the inner argument to be @()@. Useful for functions -- with overloaded return types. -- @@ -52,6 +74,19 @@ eitherM :: Monad m => (a -> m c) -> (b -> m c) -> m (Either a b) -> m c eitherM l r x = either l r =<< x +-- | A variant of 'foldM' that has no base case, and thus may only be applied to non-empty lists. +-- +-- > fold1M (\x y -> Just x) [] == undefined +-- > fold1M (\x y -> Just $ x + y) [1, 2, 3] == Just 6 +fold1M :: (Partial, Monad m) => (a -> a -> m a) -> [a] -> m a +fold1M f (x:xs) = foldM f x xs +fold1M f xs = error "fold1M: empty list" + +-- | Like 'fold1M' but discards the result. +fold1M_ :: (Partial, Monad m) => (a -> a -> m a) -> [a] -> m () +fold1M_ f xs = fold1M f xs >> return () + + -- Data.List for Monad -- | A version of 'partition' that works with a monadic predicate. @@ -91,6 +126,15 @@ -- | A looping operation, where the predicate returns 'Left' as a seed for the next loop -- or 'Right' to abort the loop. +-- +-- > loop (\x -> if x < 10 then Left $ x * 2 else Right $ show x) 1 == "16" +loop :: (a -> Either a b) -> a -> b +loop act x = case act x of + Left x -> loop act x + Right v -> v + +-- | A monadic version of 'loop', where the predicate returns 'Left' as a seed for the next loop +-- or 'Right' to abort the loop. loopM :: Monad m => (a -> m (Either a b)) -> a -> m b loopM act x = do res <- act x diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/extra-1.6.6/src/Data/List/Extra.hs new/extra-1.6.9/src/Data/List/Extra.hs --- old/extra-1.6.6/src/Data/List/Extra.hs 2018-04-16 22:51:31.000000000 +0200 +++ new/extra-1.6.9/src/Data/List/Extra.hs 2018-07-12 23:36:55.000000000 +0200 @@ -19,7 +19,7 @@ wordsBy, linesBy, breakOn, breakOnEnd, splitOn, split, chunksOf, -- * Basics - list, uncons, unsnoc, cons, snoc, drop1, mconcatMap, + notNull, list, uncons, unsnoc, cons, snoc, drop1, mconcatMap, -- * List operations groupSort, groupSortOn, groupSortBy, nubOrd, nubOrdBy, nubOrdOn, @@ -96,6 +96,14 @@ allSame (x:xs) = all (x ==) xs +-- | A composition of 'not' and 'null'. +-- +-- > notNull [] == False +-- > notNull [1] == True +-- > \xs -> notNull xs == not (null xs) +notNull :: [a] -> Bool +notNull = not . null + -- | Non-recursive transform over a list, like 'maybe'. -- -- > list 1 (\v _ -> v - 2) [5,6,7] == 3 @@ -255,7 +263,7 @@ -- | Split the first word off a string. Useful for when starting to parse the beginning --- of a string, but you want to accurately perserve whitespace in the rest of the string. +-- of a string, but you want to accurately preserve whitespace in the rest of the string. -- -- > word1 "" == ("", "") -- > word1 "keyword rest of string" == ("keyword","rest of string") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/extra-1.6.6/src/Extra.hs new/extra-1.6.9/src/Extra.hs --- old/extra-1.6.6/src/Extra.hs 2018-04-16 22:51:31.000000000 +0200 +++ new/extra-1.6.9/src/Extra.hs 2018-07-12 23:36:55.000000000 +0200 @@ -14,7 +14,7 @@ Partial, retry, retryBool, errorWithoutStackTrace, showException, stringException, errorIO, displayException, ignore, catch_, handle_, try_, catchJust_, handleJust_, tryJust_, catchBool, handleBool, tryBool, -- * Control.Monad.Extra -- | Extra functions available in @"Control.Monad.Extra"@. - whenJust, whenJustM, unit, maybeM, eitherM, loopM, whileM, partitionM, concatMapM, concatForM, mconcatMapM, mapMaybeM, findM, firstJustM, whenM, unlessM, ifM, notM, (||^), (&&^), orM, andM, anyM, allM, + whenJust, whenJustM, whenMaybe, whenMaybeM, unit, maybeM, eitherM, loop, loopM, whileM, partitionM, concatMapM, concatForM, mconcatMapM, mapMaybeM, findM, firstJustM, fold1M, fold1M_, whenM, unlessM, ifM, notM, (||^), (&&^), orM, andM, anyM, allM, -- * Data.Either.Extra -- | Extra functions available in @"Data.Either.Extra"@. isLeft, isRight, fromLeft, fromRight, fromEither, fromLeft', fromRight', eitherToMaybe, maybeToEither, @@ -23,7 +23,7 @@ modifyIORef', writeIORef', atomicModifyIORef', atomicWriteIORef, atomicWriteIORef', -- * Data.List.Extra -- | Extra functions available in @"Data.List.Extra"@. - lower, upper, trim, trimStart, trimEnd, word1, line1, escapeHTML, escapeJSON, unescapeHTML, unescapeJSON, dropEnd, takeEnd, splitAtEnd, breakEnd, spanEnd, dropWhileEnd, dropWhileEnd', takeWhileEnd, stripSuffix, stripInfix, stripInfixEnd, dropPrefix, dropSuffix, wordsBy, linesBy, breakOn, breakOnEnd, splitOn, split, chunksOf, list, uncons, unsnoc, cons, snoc, drop1, mconcatMap, groupSort, groupSortOn, groupSortBy, nubOrd, nubOrdBy, nubOrdOn, nubOn, groupOn, sortOn, nubSort, nubSortBy, nubSortOn, maximumOn, minimumOn, disjoint, allSame, anySame, repeatedly, for, firstJust, concatUnzip, concatUnzip3, zipFrom, zipWithFrom, replace, merge, mergeBy, + lower, upper, trim, trimStart, trimEnd, word1, line1, escapeHTML, escapeJSON, unescapeHTML, unescapeJSON, dropEnd, takeEnd, splitAtEnd, breakEnd, spanEnd, dropWhileEnd, dropWhileEnd', takeWhileEnd, stripSuffix, stripInfix, stripInfixEnd, dropPrefix, dropSuffix, wordsBy, linesBy, breakOn, breakOnEnd, splitOn, split, chunksOf, notNull, list, uncons, unsnoc, cons, snoc, drop1, mconcatMap, groupSort, groupSortOn, groupSortBy, nubOrd, nubOrdBy, nubOrdOn, nubOn, groupOn, sortOn, nubSort, nubSortBy, nubSortOn, maximumOn, minimumOn, disjoint, allSame, anySame, repeatedly, for, firstJust, concatUnzip, concatUnzip3, zipFrom, zipWithFrom, replace, merge, mergeBy, -- * Data.Tuple.Extra -- | Extra functions available in @"Data.Tuple.Extra"@. first, second, (***), (&&&), dupe, both, fst3, snd3, thd3, @@ -38,7 +38,7 @@ showDP, intToDouble, intToFloat, floatToDouble, doubleToFloat, -- * System.Directory.Extra -- | Extra functions available in @"System.Directory.Extra"@. - withCurrentDirectory, createDirectoryPrivate, listContents, listFiles, listFilesInside, listFilesRecursive, + withCurrentDirectory, createDirectoryPrivate, listContents, listDirectories, listFiles, listFilesInside, listFilesRecursive, -- * System.Environment.Extra -- | Extra functions available in @"System.Environment.Extra"@. getExecutablePath, lookupEnv, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/extra-1.6.6/src/System/Directory/Extra.hs new/extra-1.6.9/src/System/Directory/Extra.hs --- old/extra-1.6.6/src/System/Directory/Extra.hs 2018-04-16 22:51:31.000000000 +0200 +++ new/extra-1.6.9/src/System/Directory/Extra.hs 2018-07-12 23:36:55.000000000 +0200 @@ -17,7 +17,7 @@ withCurrentDirectory, #endif createDirectoryPrivate, - listContents, listFiles, listFilesInside, listFilesRecursive + listContents, listDirectories, listFiles, listFilesInside, listFilesRecursive ) where import System.Directory @@ -59,6 +59,15 @@ xs <- getDirectoryContents dir return $ sort [dir </> x | x <- xs, not $ all (== '.') x] + +-- | Like 'listContents', but only returns the directories in a directory, not the files. +-- Each directory will be prefixed by the query directory. +-- +-- > listTest listDirectories ["bar.txt","foo/baz.txt","zoo"] ["foo"] +listDirectories :: FilePath -> IO [FilePath] +listDirectories dir = filterM doesDirectoryExist =<< listContents dir + + -- | Like 'listContents', but only returns the files in a directory, not other directories. -- Each file will be prefixed by the query directory. -- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/extra-1.6.6/src/System/Process/Extra.hs new/extra-1.6.9/src/System/Process/Extra.hs --- old/extra-1.6.6/src/System/Process/Extra.hs 2018-04-16 22:51:31.000000000 +0200 +++ new/extra-1.6.9/src/System/Process/Extra.hs 2018-07-12 23:36:55.000000000 +0200 @@ -1,7 +1,7 @@ {-# LANGUAGE TupleSections, ConstraintKinds #-} -- | Extra functions for creating processes. Specifically variants that automatically check --- the 'ExitCode' and capture the 'stdout'\/'stderr' handles. +-- the 'ExitCode' and capture the 'stdout' \/ 'stderr' handles. module System.Process.Extra( module System.Process, system_, systemOutput, systemOutput_ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/extra-1.6.6/src/System/Time/Extra.hs new/extra-1.6.9/src/System/Time/Extra.hs --- old/extra-1.6.6/src/System/Time/Extra.hs 2018-04-16 22:51:31.000000000 +0200 +++ new/extra-1.6.9/src/System/Time/Extra.hs 2018-07-12 23:36:55.000000000 +0200 @@ -71,7 +71,7 @@ -- | Show a number of seconds, typically a duration, in a suitable manner with --- responable precision for a human. +-- reasonable precision for a human. -- -- > showDuration 3.435 == "3.44s" -- > showDuration 623.8 == "10m24s" @@ -99,7 +99,7 @@ return $ 1e-9 * fromIntegral (toNanoSecs $ end - start) where time = getTime Monotonic -{-# DEPRECATED offsetTimeIncrease "Use offsetTime instead, which is guaranteed to always increase." #-} +{-# DEPRECATED offsetTimeIncrease "Use 'offsetTime' instead, which is guaranteed to always increase." #-} -- | A synonym for 'offsetTime'. offsetTimeIncrease :: IO (IO Seconds) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/extra-1.6.6/test/TestGen.hs new/extra-1.6.9/test/TestGen.hs --- old/extra-1.6.6/test/TestGen.hs 2018-04-16 22:51:31.000000000 +0200 +++ new/extra-1.6.9/test/TestGen.hs 2018-07-12 23:36:55.000000000 +0200 @@ -25,9 +25,14 @@ testGen "retry 3 (fail \"die\") == fail \"die\"" $ retry 3 (fail "die") == fail "die" testGen "whenJust Nothing print == return ()" $ whenJust Nothing print == return () testGen "whenJust (Just 1) print == print 1" $ whenJust (Just 1) print == print 1 + testGen "whenMaybe True (print 1) == fmap Just (print 1)" $ whenMaybe True (print 1) == fmap Just (print 1) + testGen "whenMaybe False (print 1) == return Nothing" $ whenMaybe False (print 1) == return Nothing testGen "\\(x :: Maybe ()) -> unit x == x" $ \(x :: Maybe ()) -> unit x == x + testGen "fold1M (\\x y -> Just x) [] == undefined" $ erroneous $ fold1M (\x y -> Just x) [] + testGen "fold1M (\\x y -> Just $ x + y) [1, 2, 3] == Just 6" $ fold1M (\x y -> Just $ x + y) [1, 2, 3] == Just 6 testGen "partitionM (Just . even) [1,2,3] == Just ([2], [1,3])" $ partitionM (Just . even) [1,2,3] == Just ([2], [1,3]) testGen "partitionM (const Nothing) [1,2,3] == Nothing" $ partitionM (const Nothing) [1,2,3] == Nothing + testGen "loop (\\x -> if x < 10 then Left $ x * 2 else Right $ show x) 1 == \"16\"" $ loop (\x -> if x < 10 then Left $ x * 2 else Right $ show x) 1 == "16" testGen "Just True ||^ undefined == Just True" $ Just True ||^ undefined == Just True testGen "Just False ||^ Just True == Just True" $ Just False ||^ Just True == Just True testGen "Just False ||^ Just False == Just False" $ Just False ||^ Just False == Just False @@ -80,6 +85,9 @@ testGen "allSame [] == True" $ allSame [] == True testGen "allSame (1:1:2:undefined) == False" $ allSame (1:1:2:undefined) == False testGen "\\xs -> allSame xs == (length (nub xs) <= 1)" $ \xs -> allSame xs == (length (nub xs) <= 1) + testGen "notNull [] == False" $ notNull [] == False + testGen "notNull [1] == True" $ notNull [1] == True + testGen "\\xs -> notNull xs == not (null xs)" $ \xs -> notNull xs == not (null xs) testGen "list 1 (\\v _ -> v - 2) [5,6,7] == 3" $ list 1 (\v _ -> v - 2) [5,6,7] == 3 testGen "list 1 (\\v _ -> v - 2) [] == 1" $ list 1 (\v _ -> v - 2) [] == 1 testGen "\\nil cons xs -> maybe nil (uncurry cons) (uncons xs) == list nil cons xs" $ \nil cons xs -> maybe nil (uncurry cons) (uncons xs) == list nil cons xs @@ -234,6 +242,7 @@ let touch = mapM_ $ \x -> createDirectoryIfMissing True (takeDirectory x) >> writeFile x "" let listTest op as bs = withTempDir $ \dir -> do touch $ map (dir </>) as; res <- op dir; return $ map (drop (length dir + 1)) res == bs testGen "listTest listContents [\"bar.txt\",\"foo/baz.txt\",\"zoo\"] [\"bar.txt\",\"foo\",\"zoo\"]" $ listTest listContents ["bar.txt","foo/baz.txt","zoo"] ["bar.txt","foo","zoo"] + testGen "listTest listDirectories [\"bar.txt\",\"foo/baz.txt\",\"zoo\"] [\"foo\"]" $ listTest listDirectories ["bar.txt","foo/baz.txt","zoo"] ["foo"] testGen "listTest listFiles [\"bar.txt\",\"foo/baz.txt\",\"zoo\"] [\"bar.txt\",\"zoo\"]" $ listTest listFiles ["bar.txt","foo/baz.txt","zoo"] ["bar.txt","zoo"] testGen "listTest listFilesRecursive [\"bar.txt\",\"zoo\",\"foo\" </> \"baz.txt\"] [\"bar.txt\",\"zoo\",\"foo\" </> \"baz.txt\"]" $ listTest listFilesRecursive ["bar.txt","zoo","foo" </> "baz.txt"] ["bar.txt","zoo","foo" </> "baz.txt"] testGen "listTest (listFilesInside $ return . not . isPrefixOf \".\" . takeFileName) [\"bar.txt\",\"foo\" </> \"baz.txt\",\".foo\" </> \"baz2.txt\", \"zoo\"] [\"bar.txt\",\"zoo\",\"foo\" </> \"baz.txt\"]" $ listTest (listFilesInside $ return . not . isPrefixOf "." . takeFileName) ["bar.txt","foo" </> "baz.txt",".foo" </> "baz2.txt", "zoo"] ["bar.txt","zoo","foo" </> "baz.txt"]
