extra 1.6.21 → 1.7
raw patch · 5 files changed
+14/−20 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.List.Extra: for :: [a] -> (a -> b) -> [b]
- Extra: for :: [a] -> (a -> b) -> [b]
- Data.List.Extra: zipFrom :: (Partial, Enum a) => a -> [b] -> [(a, b)]
+ Data.List.Extra: zipFrom :: Enum a => a -> [b] -> [(a, b)]
- Data.List.Extra: zipWithFrom :: (Partial, Enum a) => (a -> b -> c) -> a -> [b] -> [c]
+ Data.List.Extra: zipWithFrom :: Enum a => (a -> b -> c) -> a -> [b] -> [c]
- Extra: zipFrom :: (Partial, Enum a) => a -> [b] -> [(a, b)]
+ Extra: zipFrom :: Enum a => a -> [b] -> [(a, b)]
- Extra: zipWithFrom :: (Partial, Enum a) => (a -> b -> c) -> a -> [b] -> [c]
+ Extra: zipWithFrom :: Enum a => (a -> b -> c) -> a -> [b] -> [c]
Files
- CHANGES.txt +3/−0
- extra.cabal +1/−1
- src/Data/List/Extra.hs +8/−17
- src/Extra.hs +1/−1
- test/TestGen.hs +1/−1
CHANGES.txt view
@@ -1,5 +1,8 @@ Changelog for Extra +1.7, released 2020-03-05+* #40, delete deprecated function for+* zipFrom now truncates lists, rather than error, just like zip 1.6.21, released 2020-03-02 #54, deprecate nubOn since its O(n^2). Use nubOrdOn #53, add some nub functions to NonEmpty
extra.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: extra-version: 1.6.21+version: 1.7 license: BSD3 license-file: LICENSE category: Development
src/Data/List/Extra.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TupleSections, BangPatterns, ConstraintKinds #-}+{-# LANGUAGE TupleSections, ConstraintKinds #-} -- | This module extends "Data.List" with extra functions of a similar nature. -- The package also exports the existing "Data.List" functions.@@ -29,7 +29,7 @@ nubSort, nubSortBy, nubSortOn, maximumOn, minimumOn, disjoint, allSame, anySame,- repeatedly, for, firstJust,+ repeatedly, firstJust, concatUnzip, concatUnzip3, zipFrom, zipWithFrom, replace, merge, mergeBy,@@ -59,13 +59,6 @@ where (b, as') = f as --- | /DEPRECATED/ Use @flip map@ directly, since this function clashes with @Data.Traversable.for@.------ Flipped version of 'map'.-{-# DEPRECATED for "Use flip map directly, since this function clashes with Data.Traversable.for" #-}-for :: [a] -> (a -> b) -> [b]-for = flip map- -- | Are two lists disjoint, with no elements in common. -- -- > disjoint [1,2,3] [4,5] == True@@ -211,20 +204,18 @@ -- Never truncates the output - raises an error if the enumeration runs out. -- -- > \i xs -> zip [i..] xs == zipFrom i xs--- > zipFrom False [1..3] == undefined-zipFrom :: (Partial, Enum a) => a -> [b] -> [(a, b)]+-- > zipFrom False [1..3] == [(False,1),(True, 2)]+zipFrom :: Enum a => a -> [b] -> [(a, b)] zipFrom = zipWithFrom (,) -- | 'zipFrom' generalised to any combining operation. -- Never truncates the output - raises an error if the enumeration runs out. -- -- > \i xs -> zipWithFrom (,) i xs == zipFrom i xs-zipWithFrom :: (Partial, Enum a) => (a -> b -> c) -> a -> [b] -> [c]-zipWithFrom f a xs = go a xs- where- -- if we aren't strict in the accumulator, it's highly like to be a space leak- go !a [] = []- go !a (x:xs) = f a x : go (succ a) xs+zipWithFrom :: Enum a => (a -> b -> c) -> a -> [b] -> [c]+-- would love to deforest the intermediate [a..] list+-- but would require Bounded and Eq as well, so better go for simplicit+zipWithFrom f a = zipWith f [a..] -- | A merging of 'unzip' and 'concat'.
src/Extra.hs view
@@ -23,7 +23,7 @@ writeIORef', atomicWriteIORef', atomicModifyIORef_, atomicModifyIORef'_, -- * 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', takeWhileEnd, stripSuffix, stripInfix, stripInfixEnd, dropPrefix, dropSuffix, wordsBy, linesBy, breakOn, breakOnEnd, splitOn, split, chunksOf, headDef, lastDef, notNull, list, unsnoc, cons, snoc, drop1, dropEnd1, mconcatMap, enumerate, groupSort, groupSortOn, groupSortBy, nubOrd, nubOrdBy, nubOrdOn, nubOn, groupOn, 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', takeWhileEnd, stripSuffix, stripInfix, stripInfixEnd, dropPrefix, dropSuffix, wordsBy, linesBy, breakOn, breakOnEnd, splitOn, split, chunksOf, headDef, lastDef, notNull, list, unsnoc, cons, snoc, drop1, dropEnd1, mconcatMap, enumerate, groupSort, groupSortOn, groupSortBy, nubOrd, nubOrdBy, nubOrdOn, nubOn, groupOn, nubSort, nubSortBy, nubSortOn, maximumOn, minimumOn, disjoint, allSame, anySame, repeatedly, firstJust, concatUnzip, concatUnzip3, zipFrom, zipWithFrom, replace, merge, mergeBy, -- * Data.List.NonEmpty.Extra -- | Extra functions available in @"Data.List.NonEmpty.Extra"@. (|:), (|>), appendl, appendr, maximum1, minimum1, maximumBy1, minimumBy1, maximumOn1, minimumOn1,
test/TestGen.hs view
@@ -128,7 +128,7 @@ testGen "\\i xs -> uncurry (++) (splitAt i xs) == xs" $ \i xs -> uncurry (++) (splitAt i xs) == xs testGen "\\i xs -> splitAtEnd i xs == (dropEnd i xs, takeEnd i xs)" $ \i xs -> splitAtEnd i xs == (dropEnd i xs, takeEnd i xs) testGen "\\i xs -> zip [i..] xs == zipFrom i xs" $ \i xs -> zip [i..] xs == zipFrom i xs- testGen "zipFrom False [1..3] == undefined" $ erroneous $ zipFrom False [1..3]+ testGen "zipFrom False [1..3] == [(False,1),(True, 2)]" $ zipFrom False [1..3] == [(False,1),(True, 2)] testGen "\\i xs -> zipWithFrom (,) i xs == zipFrom i xs" $ \i xs -> zipWithFrom (,) i xs == zipFrom i xs testGen "concatUnzip [(\"a\",\"AB\"),(\"bc\",\"C\")] == (\"abc\",\"ABC\")" $ concatUnzip [("a","AB"),("bc","C")] == ("abc","ABC") testGen "concatUnzip3 [(\"a\",\"AB\",\"\"),(\"bc\",\"C\",\"123\")] == (\"abc\",\"ABC\",\"123\")" $ concatUnzip3 [("a","AB",""),("bc","C","123")] == ("abc","ABC","123")