Skip to content

Drop deprecated group' and mapWithIndex #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
15 changes: 0 additions & 15 deletions src/Data/List.purs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ module Data.List
, filterM
, mapMaybe
, catMaybes
, mapWithIndex

, sort
, sortBy
Expand All @@ -68,7 +67,6 @@ module Data.List
, span
, group
, groupAll
, group'
, groupBy
, groupAllBy
, partition
Expand Down Expand Up @@ -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
Expand All @@ -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.
-- |
Expand Down Expand Up @@ -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 ---------------------------------------------------------------------
--------------------------------------------------------------------------------
Expand Down Expand Up @@ -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.
-- |
Expand Down
14 changes: 0 additions & 14 deletions src/Data/List/NonEmpty.purs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ module Data.List.NonEmpty
, mapMaybe
, catMaybes
, appendFoldable
, mapWithIndex
, sort
, sortBy
, take
Expand All @@ -42,7 +41,6 @@ module Data.List.NonEmpty
, span
, group
, groupAll
, group'
, groupBy
, groupAllBy
, partition
Expand All @@ -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(..))
Expand All @@ -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.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
5 changes: 1 addition & 4 deletions test/Test/Data/List.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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(..))
Expand Down Expand Up @@ -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]

Expand Down
3 changes: 0 additions & 3 deletions test/Test/Data/List/NonEmpty.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down