From 640150ca5fc2de760fafe1eefe14116497d131bd Mon Sep 17 00:00:00 2001 From: Tyson Whitehead Date: Wed, 28 Aug 2024 22:53:38 -0400 Subject: [PATCH 1/4] Add `imapped` (#146) --- CHANGELOG.md | 1 + src/Data/Lens/Indexed.purs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eb19aa..1038241 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: New features: +- Add `imapped` (#146 by @twhitehead) Bugfixes: diff --git a/src/Data/Lens/Indexed.purs b/src/Data/Lens/Indexed.purs index a041936..4a311d7 100644 --- a/src/Data/Lens/Indexed.purs +++ b/src/Data/Lens/Indexed.purs @@ -6,11 +6,12 @@ import Control.Monad.State (evalState, get, modify) import Data.Functor.Compose (Compose(..)) import Data.Lens.Iso.Newtype (_Newtype) import Data.Lens.Setter ((%~)) -import Data.Lens.Types (Indexed(..), IndexedOptic, IndexedTraversal, Optic, Traversal, wander) +import Data.Lens.Types (Indexed(..), IndexedOptic, IndexedSetter, IndexedTraversal, Optic, Traversal, wander) import Data.Newtype (unwrap) import Data.Profunctor (class Profunctor, dimap, lcmap) import Data.Profunctor.Star (Star(..)) import Data.Profunctor.Strong (first) +import Data.FunctorWithIndex (class FunctorWithIndex, mapWithIndex) import Data.TraversableWithIndex (class TraversableWithIndex, traverseWithIndex) import Data.Tuple (curry, fst, snd) @@ -46,6 +47,13 @@ iwander -> IndexedTraversal i s t a b iwander itr = wander (\f s -> itr (curry f) s) <<< unwrap +-- | Sets over a `FunctorWithIndex` container. +imapped + :: forall i f a b + . FunctorWithIndex i f + => IndexedSetter i (f a) (f b) a b +imapped = mapWithIndex <<< curry <<< unwrap + -- | Traverses over a `TraversableWithIndex` container. itraversed :: forall i t a b From 6ff39ddffea8fd439062511aa1b82e5a7e73f4f5 Mon Sep 17 00:00:00 2001 From: Tyson Whitehead Date: Wed, 28 Aug 2024 23:50:04 -0400 Subject: [PATCH 2/4] Add `ifolded` (#146) --- CHANGELOG.md | 2 +- src/Data/Lens/Indexed.purs | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1038241..66af655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Notable changes to this project are documented in this file. The format is based Breaking changes: New features: -- Add `imapped` (#146 by @twhitehead) +- Add `ifolded` and `imapped` (#146 by @twhitehead) Bugfixes: diff --git a/src/Data/Lens/Indexed.purs b/src/Data/Lens/Indexed.purs index 4a311d7..10d9a6f 100644 --- a/src/Data/Lens/Indexed.purs +++ b/src/Data/Lens/Indexed.purs @@ -6,11 +6,12 @@ import Control.Monad.State (evalState, get, modify) import Data.Functor.Compose (Compose(..)) import Data.Lens.Iso.Newtype (_Newtype) import Data.Lens.Setter ((%~)) -import Data.Lens.Types (Indexed(..), IndexedOptic, IndexedSetter, IndexedTraversal, Optic, Traversal, wander) -import Data.Newtype (unwrap) +import Data.Lens.Types (Indexed(..), IndexedOptic, IndexedFold, IndexedSetter, IndexedTraversal, Optic, Traversal, wander) +import Data.Newtype (wrap, unwrap) import Data.Profunctor (class Profunctor, dimap, lcmap) import Data.Profunctor.Star (Star(..)) import Data.Profunctor.Strong (first) +import Data.FoldableWithIndex (class FoldableWithIndex, foldMapWithIndex) import Data.FunctorWithIndex (class FunctorWithIndex, mapWithIndex) import Data.TraversableWithIndex (class TraversableWithIndex, traverseWithIndex) import Data.Tuple (curry, fst, snd) @@ -47,6 +48,14 @@ iwander -> IndexedTraversal i s t a b iwander itr = wander (\f s -> itr (curry f) s) <<< unwrap +-- | Folds over a `FoldableWithIndex` container. +ifolded + :: forall r i f t a b + . Monoid r + => FoldableWithIndex i f + => IndexedFold r i (f a) t a b +ifolded = wrap <<< foldMapWithIndex <<< curry <<< unwrap <<< unwrap + -- | Sets over a `FunctorWithIndex` container. imapped :: forall i f a b From ab3bd034a390955b5b54a7f3762af6df5fbd84e5 Mon Sep 17 00:00:00 2001 From: Tyson Whitehead Date: Thu, 29 Aug 2024 08:28:52 -0400 Subject: [PATCH 3/4] Update to latest package set --- packages.dhall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages.dhall b/packages.dhall index 582d6d3..188382b 100644 --- a/packages.dhall +++ b/packages.dhall @@ -1,4 +1,4 @@ let upstream = - https://raw.githubusercontent.com/purescript/package-sets/prepare-0.15/src/packages.dhall + https://raw.githubusercontent.com/purescript/package-sets/psc-0.15.15-20240829/src/packages.dhall in upstream From ae15cd3aa25a38de5929a7519f8e01a7414a5078 Mon Sep 17 00:00:00 2001 From: Tyson Whitehead Date: Fri, 6 Sep 2024 11:54:30 -0400 Subject: [PATCH 4/4] Tweak CI system as suggested by @garyb in #147 to get it building --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e721ba4..5d24f21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: run: | npm install bower pulp@16.0.0-0 npx bower install - npx pulp build -- --censor-lib --strict + npx pulp build if [ -d "test" ]; then npx pulp test fi