Skip to content

Commit d6b28b3

Browse files
Drop deprecated group' and mapWithIndex (#206)
1 parent 96f02c9 commit d6b28b3

File tree

5 files changed

+2
-36
lines changed

5 files changed

+2
-36
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based
77
Breaking changes:
88
- Update project and deps to PureScript v0.15.0 (#203 by @JordanMartinez)
99
- Drop deprecated `MonadZero` instance (#205 by @JordanMartinez)
10+
- Drop deprecated `group'` and `mapWithIndex` (#206 by @JordanMartinez)
1011

1112
New features:
1213

src/Data/List.purs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ module Data.List
5151
, filterM
5252
, mapMaybe
5353
, catMaybes
54-
, mapWithIndex
5554

5655
, sort
5756
, sortBy
@@ -68,7 +67,6 @@ module Data.List
6867
, span
6968
, group
7069
, groupAll
71-
, group'
7270
, groupBy
7371
, groupAllBy
7472
, partition
@@ -106,7 +104,6 @@ import Control.Monad.Rec.Class (class MonadRec, Step(..), tailRecM, tailRecM2)
106104
import Data.Bifunctor (bimap)
107105
import Data.Foldable (class Foldable, foldr, any, foldl)
108106
import Data.Foldable (foldl, foldr, foldMap, fold, intercalate, elem, notElem, find, findMap, any, all) as Exports
109-
import Data.FunctorWithIndex (mapWithIndex) as FWI
110107
import Data.List.Internal (emptySet, insertAndLookupBy)
111108
import Data.List.Types (List(..), (:))
112109
import Data.List.Types (NonEmptyList(..)) as NEL
@@ -117,7 +114,6 @@ import Data.Traversable (scanl, scanr) as Exports
117114
import Data.Traversable (sequence)
118115
import Data.Tuple (Tuple(..))
119116
import Data.Unfoldable (class Unfoldable, unfoldr)
120-
import Prim.TypeError (class Warn, Text)
121117

122118
-- | Convert a list into any unfoldable structure.
123119
-- |
@@ -429,13 +425,6 @@ mapMaybe f = go Nil
429425
catMaybes :: forall a. List (Maybe a) -> List a
430426
catMaybes = mapMaybe identity
431427

432-
433-
-- | Apply a function to each element and its index in a list starting at 0.
434-
-- |
435-
-- | Deprecated. Use Data.FunctorWithIndex instead.
436-
mapWithIndex :: forall a b. (Int -> a -> b) -> List a -> List b
437-
mapWithIndex = FWI.mapWithIndex
438-
439428
--------------------------------------------------------------------------------
440429
-- Sorting ---------------------------------------------------------------------
441430
--------------------------------------------------------------------------------
@@ -606,10 +595,6 @@ group = groupBy (==)
606595
groupAll :: forall a. Ord a => List a -> List (NEL.NonEmptyList a)
607596
groupAll = group <<< sort
608597

609-
-- | Deprecated previous name of `groupAll`.
610-
group' :: forall a. Warn (Text "'group\'' is deprecated, use groupAll instead") => Ord a => List a -> List (NEL.NonEmptyList a)
611-
group' = groupAll
612-
613598
-- | Group equal, consecutive elements of a list into lists, using the specified
614599
-- | equivalence relation to determine equality.
615600
-- |

src/Data/List/NonEmpty.purs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ module Data.List.NonEmpty
3232
, mapMaybe
3333
, catMaybes
3434
, appendFoldable
35-
, mapWithIndex
3635
, sort
3736
, sortBy
3837
, take
@@ -42,7 +41,6 @@ module Data.List.NonEmpty
4241
, span
4342
, group
4443
, groupAll
45-
, group'
4644
, groupBy
4745
, groupAllBy
4846
, partition
@@ -65,7 +63,6 @@ module Data.List.NonEmpty
6563
import Prelude
6664

6765
import Data.Foldable (class Foldable)
68-
import Data.FunctorWithIndex (mapWithIndex) as FWI
6966
import Data.List ((:))
7067
import Data.List as L
7168
import Data.List.Types (NonEmptyList(..))
@@ -82,8 +79,6 @@ import Data.Semigroup.Foldable (fold1, foldMap1, for1_, sequence1_, traverse1_)
8279
import Data.Semigroup.Traversable (sequence1, traverse1, traverse1Default) as Exports
8380
import Data.Traversable (scanl, scanr) as Exports
8481

85-
import Prim.TypeError (class Warn, Text)
86-
8782
-- | Internal function: any operation on a list that is guaranteed not to delete
8883
-- | all elements also applies to a NEL, this function is a helper for defining
8984
-- | those cases.
@@ -235,12 +230,6 @@ appendFoldable :: forall t a. Foldable t => NonEmptyList a -> t a -> NonEmptyLis
235230
appendFoldable (NonEmptyList (x :| xs)) ys =
236231
NonEmptyList (x :| (xs <> L.fromFoldable ys))
237232

238-
-- | Apply a function to each element and its index in a list starting at 0.
239-
-- |
240-
-- | Deprecated. Use Data.FunctorWithIndex instead.
241-
mapWithIndex :: forall a b. (Int -> a -> b) -> NonEmptyList a -> NonEmptyList b
242-
mapWithIndex = FWI.mapWithIndex
243-
244233
sort :: forall a. Ord a => NonEmptyList a -> NonEmptyList a
245234
sort xs = sortBy compare xs
246235

@@ -268,9 +257,6 @@ group = wrappedOperation "group" L.group
268257
groupAll :: forall a. Ord a => NonEmptyList a -> NonEmptyList (NonEmptyList a)
269258
groupAll = wrappedOperation "groupAll" L.groupAll
270259

271-
group' :: forall a. Warn (Text "'group\'' is deprecated, use groupAll instead") => Ord a => NonEmptyList a -> NonEmptyList (NonEmptyList a)
272-
group' = groupAll
273-
274260
groupBy :: forall a. (a -> a -> Boolean) -> NonEmptyList a -> NonEmptyList (NonEmptyList a)
275261
groupBy = wrappedOperation "groupBy" <<< L.groupBy
276262

test/Test/Data/List.purs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Data.Array as Array
66
import Data.Foldable (foldMap, foldl)
77
import Data.FoldableWithIndex (foldMapWithIndex, foldlWithIndex, foldrWithIndex)
88
import Data.Function (on)
9-
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, (!!), (..), (:), (\\))
9+
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, (!!), (..), (:), (\\))
1010
import Data.List.NonEmpty as NEL
1111
import Data.Maybe (Maybe(..), isNothing, fromJust)
1212
import Data.Monoid.Additive (Additive(..))
@@ -218,9 +218,6 @@ testList = do
218218
log "catMaybe should take an list of Maybe values and throw out Nothings"
219219
assert $ catMaybes (l [Nothing, Just 2, Nothing, Just 4]) == l [2, 4]
220220

221-
log "mapWithIndex should take a list of values and apply a function which also takes the index into account"
222-
assert $ mapWithIndex (\x ix -> x + ix) (l [0, 1, 2, 3]) == l [0, 2, 4, 6]
223-
224221
log "sort should reorder a list into ascending order based on the result of compare"
225222
assert $ sort (l [1, 3, 2, 5, 6, 4]) == l [1, 2, 3, 4, 5, 6]
226223

test/Test/Data/List/NonEmpty.purs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ testNonEmptyList = do
137137
log "catMaybe should take an list of Maybe values and throw out Nothings"
138138
assert $ NEL.catMaybes (nel Nothing [Just 2, Nothing, Just 4]) == l [2, 4]
139139

140-
log "mapWithIndex should take a list of values and apply a function which also takes the index into account"
141-
assert $ NEL.mapWithIndex (\x ix -> x + ix) (nel 0 [1, 2, 4]) == nel 0 [2, 4, 7]
142-
143140
log "sort should reorder a non-empty list into ascending order based on the result of compare"
144141
assert $ NEL.sort (nel 1 [3, 2, 5, 6, 4]) == nel 1 [2, 3, 4, 5, 6]
145142

0 commit comments

Comments
 (0)