diff --git a/CHANGELOG.md b/CHANGELOG.md index bc43e60..a3c961b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based Breaking changes: - Update project and deps to PureScript v0.15.0 (#203 by @JordanMartinez) - Drop deprecated `MonadZero` instance (#205 by @JordanMartinez) +- Drop deprecated `group'` and `mapWithIndex` (#206 by @JordanMartinez) New features: diff --git a/src/Data/List.purs b/src/Data/List.purs index db9c1cd..fc99156 100644 --- a/src/Data/List.purs +++ b/src/Data/List.purs @@ -51,7 +51,6 @@ module Data.List , filterM , mapMaybe , catMaybes - , mapWithIndex , sort , sortBy @@ -68,7 +67,6 @@ module Data.List , span , group , groupAll - , group' , groupBy , groupAllBy , partition @@ -106,7 +104,6 @@ import Control.Monad.Rec.Class (class MonadRec, Step(..), tailRecM, tailRecM2) import Data.Bifunctor (bimap) import Data.Foldable (class Foldable, foldr, any, foldl) import Data.Foldable (foldl, foldr, foldMap, fold, intercalate, elem, notElem, find, findMap, any, all) as Exports -import Data.FunctorWithIndex (mapWithIndex) as FWI import Data.List.Internal (emptySet, insertAndLookupBy) import Data.List.Types (List(..), (:)) import Data.List.Types (NonEmptyList(..)) as NEL @@ -117,7 +114,6 @@ import Data.Traversable (scanl, scanr) as Exports import Data.Traversable (sequence) import Data.Tuple (Tuple(..)) import Data.Unfoldable (class Unfoldable, unfoldr) -import Prim.TypeError (class Warn, Text) -- | Convert a list into any unfoldable structure. -- | @@ -429,13 +425,6 @@ mapMaybe f = go Nil catMaybes :: forall a. List (Maybe a) -> List a catMaybes = mapMaybe identity - --- | Apply a function to each element and its index in a list starting at 0. --- | --- | Deprecated. Use Data.FunctorWithIndex instead. -mapWithIndex :: forall a b. (Int -> a -> b) -> List a -> List b -mapWithIndex = FWI.mapWithIndex - -------------------------------------------------------------------------------- -- Sorting --------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -606,10 +595,6 @@ group = groupBy (==) groupAll :: forall a. Ord a => List a -> List (NEL.NonEmptyList a) groupAll = group <<< sort --- | Deprecated previous name of `groupAll`. -group' :: forall a. Warn (Text "'group\'' is deprecated, use groupAll instead") => Ord a => List a -> List (NEL.NonEmptyList a) -group' = groupAll - -- | Group equal, consecutive elements of a list into lists, using the specified -- | equivalence relation to determine equality. -- | diff --git a/src/Data/List/NonEmpty.purs b/src/Data/List/NonEmpty.purs index 01c3db7..ffb72ea 100644 --- a/src/Data/List/NonEmpty.purs +++ b/src/Data/List/NonEmpty.purs @@ -32,7 +32,6 @@ module Data.List.NonEmpty , mapMaybe , catMaybes , appendFoldable - , mapWithIndex , sort , sortBy , take @@ -42,7 +41,6 @@ module Data.List.NonEmpty , span , group , groupAll - , group' , groupBy , groupAllBy , partition @@ -65,7 +63,6 @@ module Data.List.NonEmpty import Prelude import Data.Foldable (class Foldable) -import Data.FunctorWithIndex (mapWithIndex) as FWI import Data.List ((:)) import Data.List as L import Data.List.Types (NonEmptyList(..)) @@ -82,8 +79,6 @@ import Data.Semigroup.Foldable (fold1, foldMap1, for1_, sequence1_, traverse1_) import Data.Semigroup.Traversable (sequence1, traverse1, traverse1Default) as Exports import Data.Traversable (scanl, scanr) as Exports -import Prim.TypeError (class Warn, Text) - -- | Internal function: any operation on a list that is guaranteed not to delete -- | all elements also applies to a NEL, this function is a helper for defining -- | those cases. @@ -235,12 +230,6 @@ appendFoldable :: forall t a. Foldable t => NonEmptyList a -> t a -> NonEmptyLis appendFoldable (NonEmptyList (x :| xs)) ys = NonEmptyList (x :| (xs <> L.fromFoldable ys)) --- | Apply a function to each element and its index in a list starting at 0. --- | --- | Deprecated. Use Data.FunctorWithIndex instead. -mapWithIndex :: forall a b. (Int -> a -> b) -> NonEmptyList a -> NonEmptyList b -mapWithIndex = FWI.mapWithIndex - sort :: forall a. Ord a => NonEmptyList a -> NonEmptyList a sort xs = sortBy compare xs @@ -268,9 +257,6 @@ group = wrappedOperation "group" L.group groupAll :: forall a. Ord a => NonEmptyList a -> NonEmptyList (NonEmptyList a) groupAll = wrappedOperation "groupAll" L.groupAll -group' :: forall a. Warn (Text "'group\'' is deprecated, use groupAll instead") => Ord a => NonEmptyList a -> NonEmptyList (NonEmptyList a) -group' = groupAll - groupBy :: forall a. (a -> a -> Boolean) -> NonEmptyList a -> NonEmptyList (NonEmptyList a) groupBy = wrappedOperation "groupBy" <<< L.groupBy diff --git a/test/Test/Data/List.purs b/test/Test/Data/List.purs index 5ac2db8..d94450b 100644 --- a/test/Test/Data/List.purs +++ b/test/Test/Data/List.purs @@ -6,7 +6,7 @@ import Data.Array as Array import Data.Foldable (foldMap, foldl) import Data.FoldableWithIndex (foldMapWithIndex, foldlWithIndex, foldrWithIndex) import Data.Function (on) -import Data.List (List(..), Pattern(..), alterAt, catMaybes, concat, concatMap, delete, deleteAt, deleteBy, drop, dropEnd, dropWhile, elemIndex, elemLastIndex, filter, filterM, findIndex, findLastIndex, foldM, fromFoldable, group, groupAll, groupAllBy, groupBy, head, init, insert, insertAt, insertBy, intersect, intersectBy, last, length, mapMaybe, mapWithIndex, modifyAt, nub, nubBy, nubByEq, nubEq, null, partition, range, reverse, singleton, snoc, sort, sortBy, span, stripPrefix, tail, take, takeEnd, takeWhile, transpose, uncons, union, unionBy, unsnoc, unzip, updateAt, zip, zipWith, zipWithA, (!!), (..), (:), (\\)) +import Data.List (List(..), Pattern(..), alterAt, catMaybes, concat, concatMap, delete, deleteAt, deleteBy, drop, dropEnd, dropWhile, elemIndex, elemLastIndex, filter, filterM, findIndex, findLastIndex, foldM, fromFoldable, group, groupAll, groupAllBy, groupBy, head, init, insert, insertAt, insertBy, intersect, intersectBy, last, length, mapMaybe, modifyAt, nub, nubBy, nubByEq, nubEq, null, partition, range, reverse, singleton, snoc, sort, sortBy, span, stripPrefix, tail, take, takeEnd, takeWhile, transpose, uncons, union, unionBy, unsnoc, unzip, updateAt, zip, zipWith, zipWithA, (!!), (..), (:), (\\)) import Data.List.NonEmpty as NEL import Data.Maybe (Maybe(..), isNothing, fromJust) import Data.Monoid.Additive (Additive(..)) @@ -218,9 +218,6 @@ testList = do log "catMaybe should take an list of Maybe values and throw out Nothings" assert $ catMaybes (l [Nothing, Just 2, Nothing, Just 4]) == l [2, 4] - log "mapWithIndex should take a list of values and apply a function which also takes the index into account" - assert $ mapWithIndex (\x ix -> x + ix) (l [0, 1, 2, 3]) == l [0, 2, 4, 6] - log "sort should reorder a list into ascending order based on the result of compare" assert $ sort (l [1, 3, 2, 5, 6, 4]) == l [1, 2, 3, 4, 5, 6] diff --git a/test/Test/Data/List/NonEmpty.purs b/test/Test/Data/List/NonEmpty.purs index 6b8e54b..665338e 100644 --- a/test/Test/Data/List/NonEmpty.purs +++ b/test/Test/Data/List/NonEmpty.purs @@ -137,9 +137,6 @@ testNonEmptyList = do log "catMaybe should take an list of Maybe values and throw out Nothings" assert $ NEL.catMaybes (nel Nothing [Just 2, Nothing, Just 4]) == l [2, 4] - log "mapWithIndex should take a list of values and apply a function which also takes the index into account" - assert $ NEL.mapWithIndex (\x ix -> x + ix) (nel 0 [1, 2, 4]) == nel 0 [2, 4, 7] - log "sort should reorder a non-empty list into ascending order based on the result of compare" assert $ NEL.sort (nel 1 [3, 2, 5, 6, 4]) == nel 1 [2, 3, 4, 5, 6]