packages feed

extra 1.6.3 → 1.6.4

raw patch · 5 files changed

+31/−4 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.List.Extra: dropPrefix :: Eq a => [a] -> [a] -> [a]
+ Data.List.Extra: dropSuffix :: Eq a => [a] -> [a] -> [a]
+ Extra: dropPrefix :: Eq a => [a] -> [a] -> [a]
+ Extra: dropSuffix :: Eq a => [a] -> [a] -> [a]

Files

CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for Extra +1.6.4, released 2018-02-23+    Add dropPrefix and dropSuffix 1.6.3, released 2018-01-26     Add maximumOn and minimumOn     #31, add nubSort, nubSortBy and nubSortOn
extra.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.18 build-type:         Simple name:               extra-version:            1.6.3+version:            1.6.4 license:            BSD3 license-file:       LICENSE category:           Development
src/Data/List/Extra.hs view
@@ -13,6 +13,7 @@     dropEnd, takeEnd, splitAtEnd, breakEnd, spanEnd,     dropWhileEnd, dropWhileEnd', takeWhileEnd,     stripSuffix, stripInfix, stripInfixEnd,+    dropPrefix, dropSuffix,     wordsBy, linesBy,     breakOn, breakOnEnd, splitOn, split, chunksOf,     -- * Basics@@ -512,8 +513,27 @@ dropWhileEnd' :: (a -> Bool) -> [a] -> [a] dropWhileEnd' p = foldr (\x xs -> if null xs && p x then [] else x : xs) [] --- | Return the prefix of the second string if its suffix--- matches the entire first string.++-- | Drops the given prefix from a list.+--   It returns the original sequence if the sequence doesn't start with the given prefix.+--+-- > dropPrefix "Mr. " "Mr. Men" == "Men"+-- > dropPrefix "Mr. " "Dr. Men" == "Dr. Men"+dropPrefix :: Eq a => [a] -> [a] -> [a]+dropPrefix a b = fromMaybe b $ stripPrefix a b+++-- | Drops the given suffix from a list.+--   It returns the original sequence if the sequence doesn't end with the given suffix.+--+-- > dropSuffix "!" "Hello World!"  == "Hello World"+-- > dropSuffix "!" "Hello World!!" == "Hello World!"+-- > dropSuffix "!" "Hello World."  == "Hello World."+dropSuffix :: Eq a => [a] -> [a] -> [a]+dropSuffix a b = fromMaybe b $ stripSuffix a b++-- | Return the prefix of the second list if its suffix+--   matches the entire first list. -- -- Examples: --
src/Extra.hs view
@@ -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, dropEnd, takeEnd, splitAtEnd, breakEnd, spanEnd, dropWhileEnd, dropWhileEnd', takeWhileEnd, stripSuffix, stripInfix, stripInfixEnd, 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, 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,     -- * Data.Tuple.Extra     -- | Extra functions available in @"Data.Tuple.Extra"@.     first, second, (***), (&&&), dupe, both, fst3, snd3, thd3,
test/TestGen.hs view
@@ -184,6 +184,11 @@     testGen "last (dropWhileEnd' even [undefined,3]) == 3" $ last (dropWhileEnd' even [undefined,3]) == 3     testGen "head (dropWhileEnd  even (3:undefined)) == 3" $ head (dropWhileEnd  even (3:undefined)) == 3     testGen "head (dropWhileEnd' even (3:undefined)) == undefined" $ erroneous $ head (dropWhileEnd' even (3:undefined))+    testGen "dropPrefix \"Mr. \" \"Mr. Men\" == \"Men\"" $ dropPrefix "Mr. " "Mr. Men" == "Men"+    testGen "dropPrefix \"Mr. \" \"Dr. Men\" == \"Dr. Men\"" $ dropPrefix "Mr. " "Dr. Men" == "Dr. Men"+    testGen "dropSuffix \"!\" \"Hello World!\"  == \"Hello World\"" $ dropSuffix "!" "Hello World!"  == "Hello World"+    testGen "dropSuffix \"!\" \"Hello World!!\" == \"Hello World!\"" $ dropSuffix "!" "Hello World!!" == "Hello World!"+    testGen "dropSuffix \"!\" \"Hello World.\"  == \"Hello World.\"" $ dropSuffix "!" "Hello World."  == "Hello World."     testGen "stripSuffix \"bar\" \"foobar\" == Just \"foo\"" $ stripSuffix "bar" "foobar" == Just "foo"     testGen "stripSuffix \"\"    \"baz\"    == Just \"baz\"" $ stripSuffix ""    "baz"    == Just "baz"     testGen "stripSuffix \"foo\" \"quux\"   == Nothing" $ stripSuffix "foo" "quux"   == Nothing