diff --git a/README.md b/README.md index d8ca805cb..eb101c078 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ and is built on top of [Cats](https://typelevel.org/cats/), and [Spire](https:// Add to your `build.sbt` ```scala libraryDependencies ++= Seq( - "io.github.sagifogel" %% "proptics-core" % "0.3.0", - "io.github.sagifogel" %% "proptics-profunctor" % "0.3.0" + "io.github.sagifogel" %% "proptics-core" % "0.3.1", + "io.github.sagifogel" %% "proptics-profunctor" % "0.3.1" ) ``` diff --git a/core/shared/src/main/scala/proptics/ALens.scala b/core/shared/src/main/scala/proptics/ALens.scala index 7cdd5d1db..2cb0c3cff 100644 --- a/core/shared/src/main/scala/proptics/ALens.scala +++ b/core/shared/src/main/scala/proptics/ALens.scala @@ -93,206 +93,206 @@ abstract class ALens_[S, T, A, B] extends Serializable { self => */ final def lensStore(s: S): (A, B => T) = withLens(sa => sbt => (sa, sbt).mapN(Tuple2.apply))(s) - /** compose this [[ALens_]] with a function lifted to a [[Getter_]], having this [[ALens_]] applied last */ - final def to[C, D](f: A => C): Getter_[S, T, C, D] = compose(Getter_[A, B, C, D](f)) + /** compose this [[ALens_]] with a function lifted to a [[Getter_]], having this [[ALens_]] applied first */ + final def to[C, D](f: A => C): Getter_[S, T, C, D] = andThen(Getter_[A, B, C, D](f)) - /** compose this [[ALens_]] with an [[Iso_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): ALens_[S, T, C, D] = new ALens_[S, T, C, D] { - final override def apply(shop: Shop[C, D, C, D]): Shop[C, D, S, T] = self.toShop compose other(shop) + /** compose this [[ALens_]] with an [[Iso_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): ALens_[S, T, C, D] = new ALens_[S, T, C, D] { + final override def apply(shop: Shop[C, D, C, D]): Shop[C, D, S, T] = self.toShop andThen other(shop) } - /** compose this [[ALens_]] with an [[Iso_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): ALens_[C, D, A, B] = + /** compose this [[ALens_]] with an [[Iso_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): ALens_[C, D, A, B] = ALens_(self.view _ compose other.view)(c => b => other.review(self.set(b)(other.view(c)))) - /** compose this [[ALens_]] with an [[AnIso_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): ALens_[S, T, C, D] = + /** compose this [[ALens_]] with an [[AnIso_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): ALens_[S, T, C, D] = ALens_(other.view _ compose self.view)(s => d => self.set(other.set(d)(self.view(s)))(s)) - /** compose this [[ALens_]] with an [[AnIso_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): ALens_[C, D, A, B] = + /** compose this [[ALens_]] with an [[AnIso_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): ALens_[C, D, A, B] = ALens_(self.view _ compose other.view)(c => b => other.review(self.set(b)(other.view(c)))) - /** compose this [[ALens_]] with an [[Lens_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): ALens_[S, T, C, D] = new ALens_[S, T, C, D] { - final override def apply(shop: Shop[C, D, C, D]): Shop[C, D, S, T] = self.toShop compose other(shop) + /** compose this [[ALens_]] with an [[Lens_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): ALens_[S, T, C, D] = new ALens_[S, T, C, D] { + final override def apply(shop: Shop[C, D, C, D]): Shop[C, D, S, T] = self.toShop andThen other(shop) } - /** compose this [[ALens_]] with an [[Lens_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): ALens_[C, D, A, B] = new ALens_[C, D, A, B] { + /** compose this [[ALens_]] with an [[Lens_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): ALens_[C, D, A, B] = new ALens_[C, D, A, B] { override private[proptics] def apply(shop: Shop[A, B, A, B]): Shop[A, B, C, D] = Shop(self.view _ compose other.view, c => b => other.over(self.set(b))(c)) } - /** compose this [[ALens_]] with an [[ALens_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): ALens_[S, T, C, D] = new ALens_[S, T, C, D] { - final override def apply(shop: Shop[C, D, C, D]): Shop[C, D, S, T] = self.toShop compose other(shop) + /** compose this [[ALens_]] with an [[ALens_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): ALens_[S, T, C, D] = new ALens_[S, T, C, D] { + final override def apply(shop: Shop[C, D, C, D]): Shop[C, D, S, T] = self.toShop andThen other(shop) } - /** compose this [[ALens_]] with an [[ALens_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): ALens_[C, D, A, B] = new ALens_[C, D, A, B] { - override private[proptics] def apply(shop: Shop[A, B, A, B]): Shop[A, B, C, D] = other.toShop compose self(shop) + /** compose this [[ALens_]] with an [[ALens_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): ALens_[C, D, A, B] = new ALens_[C, D, A, B] { + override private[proptics] def apply(shop: Shop[A, B, A, B]): Shop[A, B, C, D] = other.toShop andThen self(shop) } - /** compose this [[ALens_]] with a [[Prism_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): AffineTraversal_[S, T, C, D] = + /** compose this [[ALens_]] with a [[Prism_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): AffineTraversal_[S, T, C, D] = AffineTraversal_ { s: S => other.viewOrModify(self.view(s)).leftMap(self.set(_)(s)) } { s => d => self.set(other.set(d)(self.view(s)))(s) } - /** compose this [[ALens_]] with a [[Prism_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): AffineTraversal_[C, D, A, B] = + /** compose this [[ALens_]] with a [[Prism_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): AffineTraversal_[C, D, A, B] = AffineTraversal_((c: C) => other.viewOrModify(c).map(self.view))(c => b => other.over(self.set(b))(c)) - /** compose this [[ALens_]] with an [[APrism_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): AffineTraversal_[S, T, C, D] = + /** compose this [[ALens_]] with an [[APrism_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): AffineTraversal_[S, T, C, D] = AffineTraversal_ { s: S => other.viewOrModify(self.view(s)).leftMap(self.set(_)(s)) } { s => d => self.set(other.set(d)(self.view(s)))(s) } - /** compose this [[ALens_]] with an [[APrism_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): AffineTraversal_[C, D, A, B] = + /** compose this [[ALens_]] with an [[APrism_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): AffineTraversal_[C, D, A, B] = AffineTraversal_((c: C) => other.viewOrModify(c).map(self.view))(c => b => other.over(self.set(b))(c)) - /** compose this [[ALens_]] with an [[AffineTraversal_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = + /** compose this [[ALens_]] with an [[AffineTraversal_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = AffineTraversal_((s: S) => other.viewOrModify(self.view(s)).leftMap(self.set(_)(s)))(s => d => self.over(other.set(d))(s)) - /** compose this [[ALens_]] with an [[AffineTraversal_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = + /** compose this [[ALens_]] with an [[AffineTraversal_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = AffineTraversal_((c: C) => other.viewOrModify(c).map(self.view))(c => b => other.over(self.set(b))(c)) - /** compose this [[ALens_]] with an [[AnAffineTraversal_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[ALens_]] with an [[AnAffineTraversal_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_((s: S) => other.viewOrModify(self.view(s)).leftMap(self.set(_)(s)))(s => d => self.over(other.set(d))(s)) - /** compose this [[ALens_]] with an [[AnAffineTraversal_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[ALens_]] with an [[AnAffineTraversal_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_((c: C) => other.viewOrModify(c).map(self.view))(c => b => other.over(self.set(b))(c)) - /** compose this [[ALens_]] with an [[Traversal_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = + /** compose this [[ALens_]] with an [[Traversal_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = Traversal_.wander(new LensLike[S, T, C, D] { override def apply[F[_]](f: C => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[ALens_]] with an [[Traversal_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = + /** compose this [[ALens_]] with an [[Traversal_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = Traversal_.wander(new LensLike[C, D, A, B] { override def apply[F[_]](f: A => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF(f)) }) - /** compose this [[ALens_]] with an [[ATraversal_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[ALens_]] with an [[ATraversal_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { final override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(pafb)) }) - /** compose this [[ALens_]] with an [[ATraversal_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[ALens_]] with an [[ATraversal_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(s: C)(implicit ev: Applicative[F]): F[D] = other.traverse(s)(self.overF(pafb)) }) - /** compose this [[ALens_]] with an [[Setter_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[ALens_]] with an [[Setter_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { final override private[proptics] def apply(pab: C => D): S => T = s => self.set(other(pab)(self.view(s)))(s) } - /** compose this [[ALens_]] with an [[Setter_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[ALens_]] with an [[Setter_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[ALens_]] with an [[Getter_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { + /** compose this [[ALens_]] with an [[Getter_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { final override private[proptics] def apply(forget: Forget[C, C, D]): Forget[C, S, T] = Forget(forget.runForget compose other.view compose self.view) } - /** compose this [[ALens_]] with an [[Getter_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { + /** compose this [[ALens_]] with an [[Getter_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { override private[proptics] def apply(forget: Forget[A, A, B]): Forget[A, C, D] = Forget(forget.runForget compose self.view compose other.view) } - /** compose this [[ALens_]] with an [[Fold_]], having this [[ALens_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[ALens_]] with an [[Fold_]], having this [[ALens_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { final override def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s))(forget.runForget)) } - /** compose this [[ALens_]] with an [[Fold_]], having this [[ALens_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[ALens_]] with an [[Fold_]], having this [[ALens_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(forget.runForget compose self.view)) } - /** compose this [[ALens_]] with an [[IndexedLens_]], having this [[ALens_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedLens_[I, S, T, C, D] = + /** compose this [[ALens_]] with an [[IndexedLens_]], having this [[ALens_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedLens_[I, S, T, C, D] = IndexedLens_((s: S) => other.view(self.view(s)))(s => d => self.set(other.set(d)(self.view(s)))(s)) - /** compose this [[ALens_]] with an [[IndexedLens_]], having this [[ALens_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedLens_[I, C, D, A, B] = + /** compose this [[ALens_]] with an [[IndexedLens_]], having this [[ALens_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedLens_[I, C, D, A, B] = IndexedLens_((c: C) => other.view(c).leftMap(self.view))(c => b => other.over { case (s, _) => self.set(b)(s) }(c)) - /** compose this [[ALens_]] with an [[AnIndexedLens_]], having this [[ALens_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = + /** compose this [[ALens_]] with an [[AnIndexedLens_]], having this [[ALens_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = AnIndexedLens_((s: S) => other.view(self.view(s)))(s => d => self.set(other.set(d)(self.view(s)))(s)) - /** compose this [[ALens_]] with an [[AnIndexedLens_]], having this [[ALens_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = + /** compose this [[ALens_]] with an [[AnIndexedLens_]], having this [[ALens_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = AnIndexedLens_((c: C) => other.view(c).leftMap(self.view))(c => b => other.over { case (s, _) => self.set(b)(s) }(c)) - /** compose this [[ALens_]] with an [[IndexedTraversal_]], having this [[ALens_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[ALens_]] with an [[IndexedTraversal_]], having this [[ALens_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { final override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[ALens_]] with an [[IndexedTraversal_]], having this [[ALens_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[ALens_]] with an [[IndexedTraversal_]], having this [[ALens_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[ALens_]] with an [[IndexedSetter_]], having this [[ALens_]] applied last */ - final def compose[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[ALens_]] with an [[IndexedSetter_]], having this [[ALens_]] applied first */ + final def andThen[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { final override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = s => self.set(other.over { case (c, i) => indexed.runIndex((c, i)) }(self.view(s)))(s) } - /** compose this [[ALens_]] with an [[IndexedSetter_]], having this [[ALens_]] applied first */ - final def andThen[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[ALens_]] with an [[IndexedSetter_]], having this [[ALens_]] applied last */ + final def compose[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[Function, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[ALens_]] with an [[IndexedGetter_]], having this [[ALens_]] applied last */ - final def compose[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[ALens_]] with an [[IndexedGetter_]], having this [[ALens_]] applied first */ + final def andThen[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { final override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(indexed.runIndex.runForget compose other.view compose self.view) } - /** compose this [[ALens_]] with an [[IndexedGetter_]], having this [[ALens_]] applied first */ - final def andThen[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[ALens_]] with an [[IndexedGetter_]], having this [[ALens_]] applied last */ + final def compose[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(c => indexed.runIndex.runForget(other.view(c).leftMap(self.view))) } - /** compose this [[ALens_]] with an [[IndexedFold_]], having this [[ALens_]] applied last */ - final def compose[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[ALens_]] with an [[IndexedFold_]], having this [[ALens_]] applied first */ + final def andThen[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { final override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s))(indexed.runIndex.runForget)) } - /** compose this [[ALens_]] with an [[IndexedFold_]], having this [[ALens_]] applied first */ - final def andThen[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[ALens_]] with an [[IndexedFold_]], having this [[ALens_]] applied last */ + final def compose[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => indexed.runIndex.runForget((self.view(s), i)) }) } diff --git a/core/shared/src/main/scala/proptics/APrism.scala b/core/shared/src/main/scala/proptics/APrism.scala index 7b165acb8..c4f29ffa5 100644 --- a/core/shared/src/main/scala/proptics/APrism.scala +++ b/core/shared/src/main/scala/proptics/APrism.scala @@ -99,56 +99,56 @@ abstract class APrism_[S, T, A, B] { self => Forget(self.foldMap(_)(forget.runForget)) } - /** compose this [[APrism_]] with a function lifted to a [[Getter_]], having this [[APrism_]] applied last */ - final def to[C, D](f: A => C): Fold_[S, T, C, D] = compose(Getter_[A, B, C, D](f)) + /** compose this [[APrism_]] with a function lifted to a [[Getter_]], having this [[APrism_]] applied first */ + final def to[C, D](f: A => C): Fold_[S, T, C, D] = andThen(Getter_[A, B, C, D](f)) - /** compose this [[APrism_]] with an [[Iso_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): APrism_[S, T, C, D] = + /** compose this [[APrism_]] with an [[Iso_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): APrism_[S, T, C, D] = APrism_((s: S) => self.viewOrModify(s).map(other.view))(self.review _ compose other.review) - /** compose this [[APrism_]] with an [[Iso_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): APrism_[C, D, A, B] = + /** compose this [[APrism_]] with an [[Iso_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): APrism_[C, D, A, B] = APrism_((c: C) => self.viewOrModify(other.view(c)).leftMap(other.review))(other.review _ compose self.review) - /** compose this [[APrism_]] with an [[AnIso_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): APrism_[S, T, C, D] = + /** compose this [[APrism_]] with an [[AnIso_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): APrism_[S, T, C, D] = APrism_((s: S) => self.viewOrModify(s).map(other.view))(self.review _ compose other.review) - /** compose this [[APrism_]] with an [[AnIso_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): APrism_[C, D, A, B] = + /** compose this [[APrism_]] with an [[AnIso_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): APrism_[C, D, A, B] = APrism_((c: C) => self.viewOrModify(other.view(c)).leftMap(other.review))(other.review _ compose self.review) - /** compose this [[APrism_]] with a [[Lens_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): AffineTraversal_[S, T, C, D] = + /** compose this [[APrism_]] with a [[Lens_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): AffineTraversal_[S, T, C, D] = AffineTraversal_((s: S) => self.viewOrModify(s).map(other.view))(s => d => self.over(other.set(d)(_))(s)) - /** compose this [[APrism_]] with a [[Lens_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): AffineTraversal_[C, D, A, B] = + /** compose this [[APrism_]] with a [[Lens_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): AffineTraversal_[C, D, A, B] = AffineTraversal_ { c: C => self.viewOrModify(other.view(c)).leftMap(other.set(_)(c)) } { c => b => other.set(self.review(b))(c) } - /** compose this [[APrism_]] with an [[ALens_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): AffineTraversal_[S, T, C, D] = + /** compose this [[APrism_]] with an [[ALens_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): AffineTraversal_[S, T, C, D] = AffineTraversal_((s: S) => self.viewOrModify(s).map(other.view))(s => d => self.over(other.set(d)(_))(s)) - /** compose this [[APrism_]] with an [[ALens_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): AffineTraversal_[C, D, A, B] = + /** compose this [[APrism_]] with an [[ALens_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): AffineTraversal_[C, D, A, B] = AffineTraversal_ { c: C => self.viewOrModify(other.view(c)).leftMap(other.set(_)(c)) } { c => b => other.set(self.review(b))(c) } - /** compose this [[APrism_]] with a [[Prism_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): APrism_[S, T, C, D] = new APrism_[S, T, C, D] { + /** compose this [[APrism_]] with a [[Prism_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): APrism_[S, T, C, D] = new APrism_[S, T, C, D] { override private[proptics] def apply(market: Market[C, D, C, D]): Market[C, D, S, T] = - self.toMarket compose other(market) + self.toMarket andThen other(market) override def traverse[F[_]](s: S)(f: C => F[D])(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(f)) } - /** compose this [[APrism_]] with a [[Prism_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): APrism_[C, D, A, B] = new APrism_[C, D, A, B] { + /** compose this [[APrism_]] with a [[Prism_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): APrism_[C, D, A, B] = new APrism_[C, D, A, B] { override private[proptics] def apply(market: Market[A, B, A, B]): Market[A, B, C, D] = Market(other.viewOrModify(_).flatMap(self.viewOrModify(_).leftMap(other.review)), other.review _ compose self.review) @@ -157,184 +157,184 @@ abstract class APrism_[S, T, A, B] { self => other.traverse(s)(self.overF(f)) } - /** compose this [[APrism_]] with an [[APrism_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): APrism_[S, T, C, D] = new APrism_[S, T, C, D] { - override private[proptics] def apply(market: Market[C, D, C, D]): Market[C, D, S, T] = self.toMarket compose other(market) + /** compose this [[APrism_]] with an [[APrism_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): APrism_[S, T, C, D] = new APrism_[S, T, C, D] { + override private[proptics] def apply(market: Market[C, D, C, D]): Market[C, D, S, T] = self.toMarket andThen other(market) /** modify the focus type of an [[APrism_]] using a Functor, resulting in a change of type to the full structure */ override def traverse[F[_]](s: S)(f: C => F[D])(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(f)) } - /** compose this [[APrism_]] with an [[APrism_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): APrism_[C, D, A, B] = new APrism_[C, D, A, B] { - override private[proptics] def apply(market: Market[A, B, A, B]): Market[A, B, C, D] = other.toMarket compose self(market) + /** compose this [[APrism_]] with an [[APrism_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): APrism_[C, D, A, B] = new APrism_[C, D, A, B] { + override private[proptics] def apply(market: Market[A, B, A, B]): Market[A, B, C, D] = other.toMarket andThen self(market) /** modify the focus type of an [[APrism_]] using a [[cats.Functor]], resulting in a change of type to the full structure */ override def traverse[F[_]](s: C)(f: A => F[B])(implicit ev: Applicative[F]): F[D] = other.traverse(s)(self.overF(f)) } - /** compose this [[APrism_]] with an [[AffineTraversal_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = + /** compose this [[APrism_]] with an [[AffineTraversal_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = AffineTraversal_ { s: S => self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) } { s => d => self.over(other.set(d))(s) } - /** compose this [[APrism_]] with an [[AffineTraversal_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = + /** compose this [[APrism_]] with an [[AffineTraversal_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = AffineTraversal_ { c: C => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.set(_)(c))) } { c => b => other.over(self.set(b))(c) } - /** compose this [[APrism_]] with an [[AnAffineTraversal_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[APrism_]] with an [[AnAffineTraversal_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_ { s: S => self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) } { s => d => self.over(other.set(d))(s) } - /** compose this [[APrism_]] with an [[AnAffineTraversal_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[APrism_]] with an [[AnAffineTraversal_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_ { c: C => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.set(_)(c))) } { c => b => other.over(self.set(b))(c) } - /** compose this [[APrism_]] with a [[Traversal_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = + /** compose this [[APrism_]] with a [[Traversal_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = Traversal_.wander(new LensLike[S, T, C, D] { override def apply[F[_]](f: C => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[APrism_]] with a [[Traversal_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = + /** compose this [[APrism_]] with a [[Traversal_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = Traversal_.wander(new LensLike[C, D, A, B] { override def apply[F[_]](f: A => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF(f)) }) - /** compose this [[APrism_]] with an [[ATraversal_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[APrism_]] with an [[ATraversal_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](f: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(f)) }) - /** compose this [[APrism_]] with an [[ATraversal_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[APrism_]] with an [[ATraversal_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(s: C)(implicit ev: Applicative[F]): F[D] = other.traverse(s)(self.overF(pafb)) }) - /** compose this [[APrism_]] with a [[Setter_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[APrism_]] with a [[Setter_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = toMarket.viewOrModify(_).fold(identity, self.review _ compose other(pab)) } - /** compose this [[APrism_]] with a [[Setter_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[APrism_]] with a [[Setter_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(s => self.viewOrModify(s).fold(identity, a => self.set(pab(a))(s))) } - /** compose this [[APrism_]] with a [[Getter_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[APrism_]] with a [[Getter_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(forget.runForget compose other.view)) } - /** compose this [[APrism_]] with a [[Getter_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[APrism_]] with a [[Getter_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c))(forget.runForget)) } - /** compose this [[APrism_]] with a [[Fold_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[APrism_]] with a [[Fold_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.foldMap(_)(forget.runForget))) } - /** compose this [[APrism_]] with a [[Fold_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[APrism_]] with a [[Fold_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(self.foldMap(_)(forget.runForget))) } - /** compose this [[APrism_]] with a [[Review_]], having this [[APrism_]] applied last */ - final def compose[C, D](other: Review_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { + /** compose this [[APrism_]] with a [[Review_]], having this [[APrism_]] applied first */ + final def andThen[C, D](other: Review_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { override private[proptics] def apply(tagged: Tagged[C, D]): Tagged[S, T] = Tagged(self.review(other(tagged).runTag)) } - /** compose this [[APrism_]] with a [[Review_]], having this [[APrism_]] applied first */ - final def andThen[C, D](other: Review_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { + /** compose this [[APrism_]] with a [[Review_]], having this [[APrism_]] applied last */ + final def compose[C, D](other: Review_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { override private[proptics] def apply(tagged: Tagged[A, B]): Tagged[C, D] = Tagged(other.review(self.review(tagged.runTag))) } - /** compose this n[[APrism_]] with an [[IndexedLens_]], having this [[APrism_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this n[[APrism_]] with an [[IndexedLens_]], having this [[APrism_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[APrism_]] with an [[IndexedLens_]], having this [[APrism_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[APrism_]] with an [[IndexedLens_]], having this [[APrism_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[APrism_]] with an [[AnIndexedLens_]], having this [[APrism_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[APrism_]] with an [[AnIndexedLens_]], having this [[APrism_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[APrism_]] with an [[AnIndexedLens_]], having this [[APrism_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[APrism_]] with an [[AnIndexedLens_]], having this [[APrism_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[APrism_]] with an [[IndexedTraversal_]], having this [[APrism_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[APrism_]] with an [[IndexedTraversal_]], having this [[APrism_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[APrism_]] with an [[IndexedTraversal_]], having this [[APrism_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[APrism_]] with an [[IndexedTraversal_]], having this [[APrism_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[APrism_]] with an [[IndexedSetter_]], having this [[APrism_]] applied last */ - final def compose[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[APrism_]] with an [[IndexedSetter_]], having this [[APrism_]] applied first */ + final def andThen[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over(other.over(indexed.runIndex)) } - /** compose this [[APrism_]] with an [[IndexedSetter_]], having this [[APrism_]] applied first */ - final def andThen[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[APrism_]] with an [[IndexedSetter_]], having this [[APrism_]] applied last */ + final def compose[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[APrism_]] with an [[IndexedGetter_]], having this [[APrism_]] applied last */ - final def compose[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[APrism_]] with an [[IndexedGetter_]], having this [[APrism_]] applied first */ + final def andThen[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(indexed.runIndex.runForget compose other.view)) } - /** compose this [[APrism_]] with an [[IndexedGetter_]], having this [[APrism_]] applied first */ - final def andThen[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[APrism_]] with an [[IndexedGetter_]], having this [[APrism_]] applied last */ + final def compose[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => val (s, i) = other.view(c) @@ -342,14 +342,14 @@ abstract class APrism_[S, T, A, B] { self => } } - /** compose this [[APrism_]] with an [[IndexedFold_]], having this [[APrism_]] applied last */ - final def compose[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[APrism_]] with an [[IndexedFold_]], having this [[APrism_]] applied first */ + final def andThen[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.foldMap(_)(indexed.runIndex.runForget))) } - /** compose this [[APrism_]] with an [[IndexedFold_]], having this [[APrism_]] applied first */ - final def andThen[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[APrism_]] with an [[IndexedFold_]], having this [[APrism_]] applied last */ + final def compose[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => self.foldMap(s)(a => indexed.runIndex.runForget((a, i))) }) } diff --git a/core/shared/src/main/scala/proptics/ATraversal.scala b/core/shared/src/main/scala/proptics/ATraversal.scala index 0c7413bda..fe8e40088 100644 --- a/core/shared/src/main/scala/proptics/ATraversal.scala +++ b/core/shared/src/main/scala/proptics/ATraversal.scala @@ -175,245 +175,245 @@ abstract class ATraversal_[S, T, A, B] { self => final def unsafePartsOf(implicit ev0: Sellable[* => *, Bazaar[* => *, *, *, Unit, *]], ev1: Aux[* => *, State[List[B], *]]): Lens_[S, T, List[A], List[B]] = Bazaar.unsafePartsOf(self.toBazaar) - /** compose this [[ATraversal_]] with a function lifted to a [[Getter_]], having this [[ATraversal_]] applied last */ - final def to[C, D](f: A => C): Fold_[S, T, C, D] = compose(Getter_[A, B, C, D](f)) + /** compose this [[ATraversal_]] with a function lifted to a [[Getter_]], having this [[ATraversal_]] applied first */ + final def to[C, D](f: A => C): Fold_[S, T, C, D] = andThen(Getter_[A, B, C, D](f)) - /** compose this [[ATraversal_]] with an [[Iso_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[ATraversal_]] with an [[Iso_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](c2fd: C => F[D])(s: S)(implicit ev0: Applicative[F]): F[T] = self.traverse(s)(a => ev0.map(c2fd(other.view(a)))(other.set(_)(a))) }) - /** compose this [[ATraversal_]] with an [[Iso_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[ATraversal_]] with an [[Iso_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[ATraversal_]] with an [[AnIso_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[ATraversal_]] with an [[AnIso_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](c2fd: C => F[D])(s: S)(implicit ev0: Applicative[F]): F[T] = self.traverse(s)(a => ev0.map(c2fd(other.view(a)))(other.set(_)(a))) }) - /** compose this [[ATraversal_]] with an [[AnIso_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[ATraversal_]] with an [[AnIso_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[ATraversal_]] with a [[Lens_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[ATraversal_]] with a [[Lens_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](c2fd: C => F[D])(s: S)(implicit ev0: Applicative[F]): F[T] = self.traverse(s)(a => ev0.map(c2fd(other.view(a)))(other.set(_)(a))) }) - /** compose this [[ATraversal_]] with a [[Lens_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[ATraversal_]] with a [[Lens_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[ATraversal_]] with an [[ALens_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[ATraversal_]] with an [[ALens_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](c2fd: C => F[D])(s: S)(implicit ev0: Applicative[F]): F[T] = self.traverse(s)(a => ev0.map(c2fd(other.view(a)))(other.set(_)(a))) }) - /** compose this [[ATraversal_]] with an [[ALens_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[ATraversal_]] with an [[ALens_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[ATraversal_]] with a [[Prism_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[ATraversal_]] with a [[Prism_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(pafb)) }) - /** compose this [[ATraversal_]] with a [[Prism_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[ATraversal_]] with a [[Prism_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[ATraversal_]] with an [[APrism_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[ATraversal_]] with an [[APrism_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(pafb)) }) - /** compose this [[ATraversal_]] with an [[APrism_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[ATraversal_]] with an [[APrism_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[ATraversal_]] with an [[AffineTraversal_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[ATraversal_]] with an [[AffineTraversal_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(pafb)) }) - /** compose this [[ATraversal_]] with an [[AffineTraversal_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[ATraversal_]] with an [[AffineTraversal_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[ATraversal_]] with an [[AnAffineTraversal_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[ATraversal_]] with an [[AnAffineTraversal_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(pafb)) }) - /** compose this [[ATraversal_]] with an [[AnAffineTraversal_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[ATraversal_]] with an [[AnAffineTraversal_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[ATraversal_]] with a [[Traversal_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[ATraversal_]] with a [[Traversal_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(pafb)) }) - /** compose this [[ATraversal_]] with a [[Traversal_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[ATraversal_]] with a [[Traversal_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[ATraversal_]] with an [[ATraversal_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[ATraversal_]] with an [[ATraversal_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(pafb)) }) - /** compose this [[ATraversal_]] with an [[ATraversal_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[ATraversal_]] with an [[ATraversal_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[ATraversal_]] with a [[Setter_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[ATraversal_]] with a [[Setter_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self.over(other(pab)) } - /** compose this [[ATraversal_]] with a [[Setter_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[ATraversal_]] with a [[Setter_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other(self.over(pab)) } - /** compose this [[ATraversal_]] with a [[Getter_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[ATraversal_]] with a [[Getter_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(forget.runForget compose other.view)) } - /** compose this [[ATraversal_]] with a [[Getter_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[ATraversal_]] with a [[Getter_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c))(forget.runForget)) } - /** compose this [[ATraversal_]] with a [[Fold_]], having this [[ATraversal_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[ATraversal_]] with a [[Fold_]], having this [[ATraversal_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.foldMap(_)(forget.runForget))) } - /** compose this [[ATraversal_]] with a [[Fold_]], having this [[ATraversal_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[ATraversal_]] with a [[Fold_]], having this [[ATraversal_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(self.foldMap(_)(forget.runForget))) } - /** compose this [[ATraversal_]] with an [[IndexedLens_]], having this [[ATraversal_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[ATraversal_]] with an [[IndexedLens_]], having this [[ATraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[ATraversal_]] with an [[IndexedLens_]], having this [[ATraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[ATraversal_]] with an [[IndexedLens_]], having this [[ATraversal_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[ATraversal_]] with an [[AnIndexedLens_]], having this [[ATraversal_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[ATraversal_]] with an [[AnIndexedLens_]], having this [[ATraversal_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[ATraversal_]] with an [[AnIndexedLens_]], having this [[ATraversal_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[ATraversal_]] with an [[AnIndexedLens_]], having this [[ATraversal_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[ATraversal_]] with an [[IndexedTraversal_]], having this [[ATraversal_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[ATraversal_]] with an [[IndexedTraversal_]], having this [[ATraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[ATraversal_]] with an [[IndexedTraversal_]], having this [[ATraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[ATraversal_]] with an [[IndexedTraversal_]], having this [[ATraversal_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[Traversal_]] with an [[IndexedSetter_]], having this [[ATraversal_]] applied last */ - final def compose[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[Traversal_]] with an [[IndexedSetter_]], having this [[ATraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over(other.over(indexed.runIndex)) } - /** compose this [[Traversal_]] with an [[IndexedSetter_]], having this [[ATraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[Traversal_]] with an [[IndexedSetter_]], having this [[ATraversal_]] applied last */ + final def compose[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[Traversal_]] with an [[IndexedGetter_]], having this [[ATraversal_]] applied last */ - final def compose[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Traversal_]] with an [[IndexedGetter_]], having this [[ATraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(indexed.runIndex.runForget compose other.view)) } - /** compose this [[Traversal_]] with an [[IndexedGetter_]], having this [[ATraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Traversal_]] with an [[IndexedGetter_]], having this [[ATraversal_]] applied last */ + final def compose[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => val (s, i) = other.view(c) @@ -421,14 +421,14 @@ abstract class ATraversal_[S, T, A, B] { self => } } - /** compose this [[ATraversal_]] with an [[IndexedFold_]], having this [[ATraversal_]] applied last */ - final def compose[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[ATraversal_]] with an [[IndexedFold_]], having this [[ATraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.foldMap(_)(indexed.runIndex.runForget))) } - /** compose this [[ATraversal_]] with an [[IndexedFold_]], having this [[ATraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[ATraversal_]] with an [[IndexedFold_]], having this [[ATraversal_]] applied last */ + final def compose[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => self.foldMap(s)(a => indexed.runIndex.runForget((a, i))) }) } diff --git a/core/shared/src/main/scala/proptics/AffineTraversal.scala b/core/shared/src/main/scala/proptics/AffineTraversal.scala index b574f56d2..be3bab4d3 100644 --- a/core/shared/src/main/scala/proptics/AffineTraversal.scala +++ b/core/shared/src/main/scala/proptics/AffineTraversal.scala @@ -92,27 +92,27 @@ abstract class AffineTraversal_[S, T, A, B] extends Serializable { self => Forget(self.foldMap(_)(forget.runForget)) } - /** compose this [[AffineTraversal_]] with a function lifted to a [[Getter_]], having this [[AffineTraversal_]] applied last */ - final def to[C, D](f: A => C): Fold_[S, T, C, D] = compose(Getter_[A, B, C, D](f)) + /** compose this [[AffineTraversal_]] with a function lifted to a [[Getter_]], having this [[AffineTraversal_]] applied first */ + final def to[C, D](f: A => C): Fold_[S, T, C, D] = andThen(Getter_[A, B, C, D](f)) - /** compose this [[AffineTraversal_]] with an [[Iso_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { + /** compose this [[AffineTraversal_]] with an [[Iso_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { final override def apply[P[_, _]](pab: P[C, D])(implicit ev0: Choice[P], ev1: Strong[P]): P[S, T] = self(other(pab)(ev1)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ final override def viewOrModify(s: S): Either[T, C] = self.viewOrModify(s).map(other.view) } - /** compose this [[AffineTraversal_]] with an [[Iso_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { + /** compose this [[AffineTraversal_]] with an [[Iso_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev0: Choice[P], ev1: Strong[P]): P[C, D] = other(self(pab))(ev1) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ override def viewOrModify(c: C): Either[D, A] = self.viewOrModify(other.view(c)).leftMap(other.review) } - /** compose this [[AffineTraversal_]] with an [[AnIso_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { + /** compose this [[AffineTraversal_]] with an [[AnIso_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { final override def apply[P[_, _]](pab: P[C, D])(implicit ev0: Choice[P], ev1: Strong[P]): P[S, T] = self(ev1.dimap(pab)(other.view)(other.review)) @@ -120,8 +120,8 @@ abstract class AffineTraversal_[S, T, A, B] extends Serializable { self => final override def viewOrModify(s: S): Either[T, C] = self.viewOrModify(s).map(other.view) } - /** compose this [[AffineTraversal_]] with an [[AnIso_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { + /** compose this [[AffineTraversal_]] with an [[AnIso_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev0: Choice[P], ev1: Strong[P]): P[C, D] = ev1.dimap(self(pab))(other.view)(other.review) @@ -129,36 +129,36 @@ abstract class AffineTraversal_[S, T, A, B] extends Serializable { self => override def viewOrModify(c: C): Either[D, A] = self.viewOrModify(other.view(c)).leftMap(other.review) } - /** compose this [[AffineTraversal_]] with a [[Lens_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { + /** compose this [[AffineTraversal_]] with a [[Lens_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { final override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev0: Choice[P], ev1: Strong[P]): P[S, T] = self(other(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ final override def viewOrModify(s: S): Either[T, C] = self.viewOrModify(s).map(other.view) } - /** compose this [[AffineTraversal_]] with a [[Lens_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { + /** compose this [[AffineTraversal_]] with a [[Lens_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev0: Choice[P], ev1: Strong[P]): P[C, D] = other(self(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ override def viewOrModify(c: C): Either[D, A] = self.viewOrModify(other.view(c)).leftMap(other.set(_)(c)) } - /** compose this [[AffineTraversal_]] with an [[ALens_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): AffineTraversal_[S, T, C, D] = + /** compose this [[AffineTraversal_]] with an [[ALens_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): AffineTraversal_[S, T, C, D] = AffineTraversal_[S, T, C, D] { s: S => self.viewOrModify(s).map(other.view) } { s => d => self.over(other.set(d))(s) } - /** compose this [[AffineTraversal_]] with an [[ALens_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): AffineTraversal_[C, D, A, B] = + /** compose this [[AffineTraversal_]] with an [[ALens_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): AffineTraversal_[C, D, A, B] = AffineTraversal_ { c: C => self.viewOrModify(other.view(c)).leftMap(other.set(_)(c)) } { c => b => other.over(self.set(b))(c) } - /** compose this [[AffineTraversal_]] with a [[Prism_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { + /** compose this [[AffineTraversal_]] with a [[Prism_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { final override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev0: Choice[P], ev1: Strong[P]): P[S, T] = self(other(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ @@ -166,8 +166,8 @@ abstract class AffineTraversal_[S, T, A, B] extends Serializable { self => self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) } - /** compose this [[AffineTraversal_]] with a [[Prism_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { + /** compose this [[AffineTraversal_]] with a [[Prism_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev0: Choice[P], ev1: Strong[P]): P[C, D] = other(self(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ @@ -175,28 +175,28 @@ abstract class AffineTraversal_[S, T, A, B] extends Serializable { self => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.set(_)(c))) } - /** compose this [[AffineTraversal_]] with an [[APrism_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): AffineTraversal_[S, T, C, D] = + /** compose this [[AffineTraversal_]] with an [[APrism_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): AffineTraversal_[S, T, C, D] = AffineTraversal_ { s: S => self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) } { s => d => self.over(other.set(d))(s) } - /** compose this [[AffineTraversal_]] with an [[APrism_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): AffineTraversal_[C, D, A, B] = + /** compose this [[AffineTraversal_]] with an [[APrism_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): AffineTraversal_[C, D, A, B] = AffineTraversal_ { c: C => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.set(_)(c))) } { c => b => other.over(self.set(b))(c) } - /** compose this [[AffineTraversal_]] with an [[APrism_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { + /** compose this [[AffineTraversal_]] with an [[APrism_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { final override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev0: Choice[P], ev1: Strong[P]): P[S, T] = self(other(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ final override def viewOrModify(s: S): Either[T, C] = self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) } - /** compose this [[AffineTraversal_]] with an [[APrism_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { + /** compose this [[AffineTraversal_]] with an [[APrism_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev0: Choice[P], ev1: Strong[P]): P[C, D] = other(self(pab)) @@ -205,137 +205,137 @@ abstract class AffineTraversal_[S, T, A, B] extends Serializable { self => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.set(_)(c))) } - /** compose this [[AffineTraversal_]] with an [[AnAffineTraversal_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = + /** compose this [[AffineTraversal_]] with an [[AnAffineTraversal_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = AffineTraversal_ { s: S => self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) } { s => d => self.over(other.set(d))(s) } - /** compose this [[AffineTraversal_]] with an [[AnAffineTraversal_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = + /** compose this [[AffineTraversal_]] with an [[AnAffineTraversal_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = AffineTraversal_ { c: C => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.set(_)(c))) } { c => b => other.over(self.set(b))(c) } - /** compose this [[AffineTraversal_]] with a [[Traversal_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { + /** compose this [[AffineTraversal_]] with a [[Traversal_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { final override def apply[P[_, _]](pab: P[C, D])(implicit ev: Wander[P]): P[S, T] = self(other(pab)) } - /** compose this [[AffineTraversal_]] with a [[Traversal_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { + /** compose this [[AffineTraversal_]] with a [[Traversal_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Wander[P]): P[C, D] = other(self(pab)) } - /** compose this [[AffineTraversal_]] with an [[ATraversal_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[AffineTraversal_]] with an [[ATraversal_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { final override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(pafb)) }) - /** compose this [[AffineTraversal_]] with an [[ATraversal_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[AffineTraversal_]] with an [[ATraversal_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[AffineTraversal_]] with a [[Setter_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[AffineTraversal_]] with a [[Setter_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { final override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[AffineTraversal_]] with a [[Setter_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[AffineTraversal_]] with a [[Setter_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other(self(pab)) } - /** compose this [[AffineTraversal_]] with a [[Getter_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[AffineTraversal_]] with a [[Getter_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(forget.runForget compose other.view)) } - /** compose this [[AffineTraversal_]] with a [[Getter_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[AffineTraversal_]] with a [[Getter_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c))(forget.runForget)) } - /** compose this [[AffineTraversal_]] with a [[Fold_]], having this [[AffineTraversal_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[AffineTraversal_]] with a [[Fold_]], having this [[AffineTraversal_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { final override def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = self(other(forget)) } - /** compose this [[AffineTraversal_]] with a [[Fold_]], having this [[AffineTraversal_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[AffineTraversal_]] with a [[Fold_]], having this [[AffineTraversal_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(self.foldMap(_)(forget.runForget))) } - /** compose this [[AffineTraversal_]] with an [[IndexedLens_]], having this [[AffineTraversal_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AffineTraversal_]] with an [[IndexedLens_]], having this [[AffineTraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { final override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[AffineTraversal_]] with an [[IndexedLens_]], having this [[AffineTraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AffineTraversal_]] with an [[IndexedLens_]], having this [[AffineTraversal_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[AffineTraversal_]] with an [[AnIndexedLens_]], having this [[AffineTraversal_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AffineTraversal_]] with an [[AnIndexedLens_]], having this [[AffineTraversal_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { final override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[AffineTraversal_]] with an [[AnIndexedLens_]], having this [[AffineTraversal_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AffineTraversal_]] with an [[AnIndexedLens_]], having this [[AffineTraversal_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[AffineTraversal_]] with an [[IndexedTraversal_]], having this [[AffineTraversal_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AffineTraversal_]] with an [[IndexedTraversal_]], having this [[AffineTraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { final override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[AffineTraversal_]] with an [[IndexedTraversal_]], having this [[AffineTraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AffineTraversal_]] with an [[IndexedTraversal_]], having this [[AffineTraversal_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[AffineTraversal_]] with an [[IndexedSetter_]], having this [[AffineTraversal_]] applied last */ - final def compose[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[AffineTraversal_]] with an [[IndexedSetter_]], having this [[AffineTraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { final override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over(other.over(indexed.runIndex)) } - /** compose this [[AffineTraversal_]] with an [[IndexedSetter_]], having this [[AffineTraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[AffineTraversal_]] with an [[IndexedSetter_]], having this [[AffineTraversal_]] applied last */ + final def compose[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[Function, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[AffineTraversal_]] with an [[IndexedFold_]], having this [[AffineTraversal_]] applied last */ - final def compose[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[AffineTraversal_]] with an [[IndexedFold_]], having this [[AffineTraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { final override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(indexed.runIndex.runForget compose other.view)) } - /** compose this [[AffineTraversal_]] with an [[IndexedFold_]], having this [[AffineTraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[AffineTraversal_]] with an [[IndexedFold_]], having this [[AffineTraversal_]] applied last */ + final def compose[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => val (s, i) = other.view(c) @@ -343,14 +343,14 @@ abstract class AffineTraversal_[S, T, A, B] extends Serializable { self => } } - /** compose this [[AffineTraversal_]] with an [[IndexedFold_]], having this [[AffineTraversal_]] applied last */ - final def compose[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[AffineTraversal_]] with an [[IndexedFold_]], having this [[AffineTraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { final override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.foldMap(_)(indexed.runIndex.runForget))) } - /** compose this [[AffineTraversal_]] with an [[IndexedFold_]], having this [[AffineTraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[AffineTraversal_]] with an [[IndexedFold_]], having this [[AffineTraversal_]] applied last */ + final def compose[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => self.foldMap(s)(a => indexed.runIndex.runForget((a, i))) diff --git a/core/shared/src/main/scala/proptics/AnAffineTraversal.scala b/core/shared/src/main/scala/proptics/AnAffineTraversal.scala index c7367575d..cbcdca181 100644 --- a/core/shared/src/main/scala/proptics/AnAffineTraversal.scala +++ b/core/shared/src/main/scala/proptics/AnAffineTraversal.scala @@ -103,229 +103,229 @@ abstract class AnAffineTraversal_[S, T, A, B] extends Serializable { self => Forget(self.foldMap(_)(forget.runForget)) } - /** compose this [[AnAffineTraversal_]] with a function lifted to a [[Getter_]], having this [[AnAffineTraversal_]] applied last */ - final def to[C, D](f: A => C): Fold_[S, T, C, D] = compose(Getter_[A, B, C, D](f)) + /** compose this [[AnAffineTraversal_]] with a function lifted to a [[Getter_]], having this [[AnAffineTraversal_]] applied first */ + final def to[C, D](f: A => C): Fold_[S, T, C, D] = andThen(Getter_[A, B, C, D](f)) - /** compose this [[AnAffineTraversal_]] with an [[Iso_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with an [[Iso_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_ { s: S => self.viewOrModify(s).map(other.view) } { s => d => self.over(other.set(d))(s) } - /** compose this [[AnAffineTraversal_]] with an [[Iso_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with an [[Iso_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_ { c: C => self.viewOrModify(other.view(c)).leftMap(other.review) } { c => b => other.over(s => self.set(b)(s))(c) } - /** compose this [[AnAffineTraversal_]] with an [[AnIso_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with an [[AnIso_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_ { s: S => self.viewOrModify(s).map(other.view) } { s => d => self.over(other.set(d))(s) } - /** compose this [[AnAffineTraversal_]] with an [[AnIso_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with an [[AnIso_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_ { c: C => self.viewOrModify(other.view(c)).leftMap(other.review) } { c => b => other.over(s => self.set(b)(s))(c) } - /** compose this [[AnAffineTraversal_]] with a [[Lens_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with a [[Lens_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_ { s: S => self.viewOrModify(s).map(other.view) } { s => d => self.over(other.set(d))(s) } - /** compose this [[AnAffineTraversal_]] with a [[Lens_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with a [[Lens_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_ { c: C => self.viewOrModify(other.view(c)).leftMap(other.set(_)(c)) } { c => b => other.over(s => self.set(b)(s))(c) } - /** compose this [[AnAffineTraversal_]] with an [[ALens_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with an [[ALens_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_ { s: S => self.viewOrModify(s).map(other.view) } { s => d => self.over(other.set(d))(s) } - /** compose this [[AnAffineTraversal_]] with an [[ALens_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with an [[ALens_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_ { c: C => self.viewOrModify(other.view(c)).leftMap(other.set(_)(c)) } { c => b => other.over(s => self.set(b)(s))(c) } - /** compose this [[AnAffineTraversal_]] with a [[Prism_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with a [[Prism_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_ { s: S => self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) } { s => d => self.over(other.set(d))(s) } - /** compose this [[AnAffineTraversal_]] with a [[Prism_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with a [[Prism_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_ { c: C => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.set(_)(c))) } { c => b => other.over(s => self.set(b)(s))(c) } - /** compose this [[AnAffineTraversal_]] with an [[APrism_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with an [[APrism_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_ { s: S => self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) } { s => d => self.over(other.set(d))(s) } - /** compose this [[AnAffineTraversal_]] with an [[APrism_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with an [[APrism_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_ { c: C => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.set(_)(c))) } { c => b => other.over(s => self.set(b)(s))(c) } - /** compose this [[AnAffineTraversal_]] with an [[AffineTraversal_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with an [[AffineTraversal_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_ { s: S => self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) } { s => d => self.over(other.set(d))(s) } - /** compose this [[AnAffineTraversal_]] with an [[AffineTraversal_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with an [[AffineTraversal_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_ { c: C => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.set(_)(c))) } { c => b => other.over(s => self.set(b)(s))(c) } - /** compose this [[AnAffineTraversal_]] with an [[AnAffineTraversal_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with an [[AnAffineTraversal_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_ { s: S => self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) } { s => d => self.over(other.set(d))(s) } - /** compose this [[AnAffineTraversal_]] with an [[AnAffineTraversal_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with an [[AnAffineTraversal_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_ { c: C => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.set(_)(c))) } { c => b => other.over(s => self.set(b)(s))(c) } - /** compose this [[AnAffineTraversal_]] with a [[Traversal_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with a [[Traversal_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = Traversal_.wander(new LensLike[S, T, C, D] { override def apply[F[_]](f: C => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[AnAffineTraversal_]] with a [[Traversal_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with a [[Traversal_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = Traversal_.wander(new LensLike[C, D, A, B] { override def apply[F[_]](f: A => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF(f)) }) - /** compose this [[AnAffineTraversal_]] with an [[ATraversal_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with an [[ATraversal_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(pafb)) }) - /** compose this [[AnAffineTraversal_]] with an [[ATraversal_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with an [[ATraversal_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[AnAffineTraversal_]] with a [[Setter_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[AnAffineTraversal_]] with a [[Setter_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self.over(other.over(pab)) } - /** compose this [[AnAffineTraversal_]] with a [[Setter_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[AnAffineTraversal_]] with a [[Setter_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other(self.over(pab)) } - /** compose an [[AnAffineTraversal_]] with a [[Getter_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose an [[AnAffineTraversal_]] with a [[Getter_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(forget.runForget compose other.view)) } - /** compose an [[AnAffineTraversal_]] with a [[Getter_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose an [[AnAffineTraversal_]] with a [[Getter_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c))(forget.runForget)) } - /** compose an [[AnAffineTraversal_]] with a [[Fold_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose an [[AnAffineTraversal_]] with a [[Fold_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.foldMap(_)(forget.runForget))) } - /** compose this [[AnAffineTraversal_]] with a [[Fold_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[AnAffineTraversal_]] with a [[Fold_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(self.foldMap(_)(forget.runForget))) } - /** compose this [[AnAffineTraversal_]] with an [[IndexedLens_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with an [[IndexedLens_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[AnAffineTraversal_]] with an [[IndexedLens_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with an [[IndexedLens_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[AnAffineTraversal_]] with an [[AnIndexedLens_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with an [[AnIndexedLens_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[AnAffineTraversal_]] with an [[AnIndexedLens_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with an [[AnIndexedLens_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[AnAffineTraversal_]] with an [[IndexedTraversal_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AnAffineTraversal_]] with an [[IndexedTraversal_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[AnAffineTraversal_]] with an [[IndexedTraversal_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AnAffineTraversal_]] with an [[IndexedTraversal_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[AnAffineTraversal_]] with an [[IndexedSetter_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[AnAffineTraversal_]] with an [[IndexedSetter_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over(other.over(indexed.runIndex)) } - /** compose this [[AnAffineTraversal_]] with an [[IndexedSetter_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[AnAffineTraversal_]] with an [[IndexedSetter_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[AnAffineTraversal_]] with an [[IndexedGetter_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[AnAffineTraversal_]] with an [[IndexedGetter_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(indexed.runIndex.runForget compose other.view)) } - /** compose this [[AnAffineTraversal_]] with an [[IndexedGetter_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[AnAffineTraversal_]] with an [[IndexedGetter_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => val (s, i) = other.view(c) @@ -333,14 +333,14 @@ abstract class AnAffineTraversal_[S, T, A, B] extends Serializable { self => } } - /** compose this [[AnAffineTraversal_]] with an [[IndexedFold_]], having this [[AnAffineTraversal_]] applied last */ - final def compose[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[AnAffineTraversal_]] with an [[IndexedFold_]], having this [[AnAffineTraversal_]] applied first */ + final def andThen[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.foldMap(_)(indexed.runIndex.runForget))) } - /** compose this [[AnAffineTraversal_]] with an [[IndexedFold_]], having this [[AnAffineTraversal_]] applied first */ - final def andThen[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[AnAffineTraversal_]] with an [[IndexedFold_]], having this [[AnAffineTraversal_]] applied last */ + final def compose[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => self.foldMap(s)(a => indexed.runIndex.runForget((a, i))) }) } diff --git a/core/shared/src/main/scala/proptics/AnIndexedLens.scala b/core/shared/src/main/scala/proptics/AnIndexedLens.scala index 3a3cae3a0..a2f8c0215 100644 --- a/core/shared/src/main/scala/proptics/AnIndexedLens.scala +++ b/core/shared/src/main/scala/proptics/AnIndexedLens.scala @@ -103,136 +103,136 @@ abstract class AnIndexedLens_[I, S, T, A, B] { self => Forget(indexed.runIndex.runForget compose self.view) } - /** compose this [[AnIndexedLens_]] with an [[Iso_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = + /** compose this [[AnIndexedLens_]] with an [[Iso_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = AnIndexedLens_((s: S) => self.view(s).leftMap(other.view))(s => d => self.set(other.set(d)(self.view(s)._1))(s)) - /** compose this [[AnIndexedLens_]] with an [[Iso_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = + /** compose this [[AnIndexedLens_]] with an [[Iso_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = AnIndexedLens_((c: C) => self.view(other.view(c)))(c => b => other.review(self.set(b)(other.view(c)))) - /** compose this [[AnIndexedLens_]] with an [[AnIso_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = + /** compose this [[AnIndexedLens_]] with an [[AnIso_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = AnIndexedLens_((s: S) => self.view(s).leftMap(other.view))(s => d => self.set(other.set(d)(self.view(s)._1))(s)) - /** compose this [[AnIndexedLens_]] with an [[AnIso_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = + /** compose this [[AnIndexedLens_]] with an [[AnIso_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = AnIndexedLens_((c: C) => self.view(other.view(c)))(c => b => other.review(self.set(b)(other.view(c)))) - /** compose this [[AnIndexedLens_]] with a [[Lens_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = + /** compose this [[AnIndexedLens_]] with a [[Lens_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = AnIndexedLens_((s: S) => self.view(s).leftMap(other.view))(s => d => self.set(other.set(d)(self.view(s)._1))(s)) - /** compose this [[AnIndexedLens_]] with a [[Lens_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = + /** compose this [[AnIndexedLens_]] with a [[Lens_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = AnIndexedLens_((c: C) => self.view(other.view(c)))(c => b => other.set(self.set(b)(other.view(c)))(c)) - /** compose this [[AnIndexedLens_]] with an [[ALens_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = + /** compose this [[AnIndexedLens_]] with an [[ALens_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = AnIndexedLens_((s: S) => self.view(s).leftMap(other.view))(s => d => self.set(other.set(d)(self.view(s)._1))(s)) - /** compose this [[AnIndexedLens_]] with an [[ALens_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = + /** compose this [[AnIndexedLens_]] with an [[ALens_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = AnIndexedLens_((c: C) => self.view(other.view(c)))(c => b => other.set(self.set(b)(other.view(c)))(c)) - /** compose this [[AnIndexedLens_]] with a [[Prism_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AnIndexedLens_]] with a [[Prism_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.overF(c => f((c, i)))(a) } }) - /** compose this [[AnIndexedLens_]] with a [[Prism_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AnIndexedLens_]] with a [[Prism_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[AnIndexedLens_]] with an [[APrism_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AnIndexedLens_]] with an [[APrism_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.overF(c => f((c, i)))(a) } }) - /** compose this [[AnIndexedLens_]] with an [[APrism_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AnIndexedLens_]] with an [[APrism_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[AnIndexedLens_]] with an [[AffineTraversal_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AnIndexedLens_]] with an [[AffineTraversal_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.overF(c => f((c, i)))(a) } }) - /** compose this [[AnIndexedLens_]] with an [[AffineTraversal_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AnIndexedLens_]] with an [[AffineTraversal_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[AnIndexedLens_]] with an [[AnAffineTraversal_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AnIndexedLens_]] with an [[AnAffineTraversal_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.overF(c => f((c, i)))(a) } }) - /** compose this [[AnIndexedLens_]] with an [[AnAffineTraversal_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AnIndexedLens_]] with an [[AnAffineTraversal_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[AnIndexedLens_]] with a [[Traversal_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AnIndexedLens_]] with a [[Traversal_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.overF(c => f((c, i)))(a) } }) - /** compose this [[AnIndexedLens_]] with a [[Traversal_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AnIndexedLens_]] with a [[Traversal_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[AnIndexedLens_]] with an [[ATraversal_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AnIndexedLens_]] with an [[ATraversal_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.overF(c => f((c, i)))(a) } }) - /** compose this [[AnIndexedLens_]] with an [[ATraversal_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AnIndexedLens_]] with an [[ATraversal_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[AnIndexedLens_]] with a [[Setter_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, (C, I), D] = new Setter_[S, T, (C, I), D] { + /** compose this [[AnIndexedLens_]] with a [[Setter_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, (C, I), D] = new Setter_[S, T, (C, I), D] { override private[proptics] def apply(pab: ((C, I)) => D): S => T = self.over { case (a, i) => other.over(c => pab((c, i)))(a) } } - /** compose this [[AnIndexedLens_]] with a [[Setter_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, (A, I), B] = new Setter_[C, D, (A, I), B] { + /** compose this [[AnIndexedLens_]] with a [[Setter_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, (A, I), B] = new Setter_[C, D, (A, I), B] { override private[proptics] def apply(pab: ((A, I)) => B): C => D = other.over(self.over { case (a, i) => pab((a, i)) }) } - /** compose this [[AnIndexedLens_]] with a [[Getter_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Getter_[S, T, (C, I), D] = new Getter_[S, T, (C, I), D] { + /** compose this [[AnIndexedLens_]] with a [[Getter_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Getter_[S, T, (C, I), D] = new Getter_[S, T, (C, I), D] { override private[proptics] def apply(forget: Forget[(C, I), (C, I), D]): Forget[(C, I), S, T] = Forget { s => val (a, i) = self.view(s) @@ -240,8 +240,8 @@ abstract class AnIndexedLens_[I, S, T, A, B] { self => } } - /** compose this [[AnIndexedLens_]] with a [[Getter_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Getter_[C, D, (A, I), B] = new Getter_[C, D, (A, I), B] { + /** compose this [[AnIndexedLens_]] with a [[Getter_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Getter_[C, D, (A, I), B] = new Getter_[C, D, (A, I), B] { override private[proptics] def apply(forget: Forget[(A, I), (A, I), B]): Forget[(A, I), C, D] = Forget { c => val (a, i) = self.view(other.view(c)) @@ -249,8 +249,8 @@ abstract class AnIndexedLens_[I, S, T, A, B] { self => } } - /** compose this [[AnIndexedLens_]] with a [[Fold_]], having this [[AnIndexedLens_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, (C, I), D] = new Fold_[S, T, (C, I), D] { + /** compose this [[AnIndexedLens_]] with a [[Fold_]], having this [[AnIndexedLens_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, (C, I), D] = new Fold_[S, T, (C, I), D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, (C, I), D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -258,78 +258,78 @@ abstract class AnIndexedLens_[I, S, T, A, B] { self => } } - /** compose this [[AnIndexedLens_]] with a [[Fold_]], having this [[AnIndexedLens_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, (A, I), B] = new Fold_[C, D, (A, I), B] { + /** compose this [[AnIndexedLens_]] with a [[Fold_]], having this [[AnIndexedLens_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, (A, I), B] = new Fold_[C, D, (A, I), B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, (A, I), B]): Forget[R, C, D] = Forget(other.foldMap(_)(forget.runForget compose self.view)) } /** compose an [[AnIndexedLens_]] with an [[IndexedLens_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedLens_[J, A, B, C, D]): AnIndexedLens_[J, S, T, C, D] = new AnIndexedLens_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedLens_[J, A, B, C, D]): AnIndexedLens_[J, S, T, C, D] = new AnIndexedLens_[J, S, T, C, D] { final def apply(indexed: Indexed[Shop[(C, J), D, *, *], J, C, D]): Shop[(C, J), D, S, T] = Shop(other.view _ compose Tuple2._1[A, I] compose self.view, s => d => self.set(other.set(d)(self.view(s)._1))(s)) } /** compose an [[AnIndexedLens_]] with an [[IndexedLens_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedLens_[J, A, B, C, D]): AnIndexedLens_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedLens_[J, A, B, C, D]): AnIndexedLens_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[AnIndexedLens_]] with an [[IndexedLens_]], while preserving the indices of the other optic */ - final def composeWithLeftIndex[C, D](other: IndexedLens_[_, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = new AnIndexedLens_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedLens_[_, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = new AnIndexedLens_[I, S, T, C, D] { final def apply(indexed: Indexed[Shop[(C, I), D, *, *], I, C, D]): Shop[(C, I), D, S, T] = Shop(self.view(_).leftMap(other.view(_)._1), s => d => self.set(other.set(d)(self.view(s)._1))(s)) } /** compose an [[AnIndexedLens_]] with an [[IndexedLens_]], while preserving self indices */ - final def <<*[C, D](other: IndexedLens_[_, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedLens_[_, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose an [[AnIndexedLens_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): AnIndexedLens_[J, S, T, C, D] = new AnIndexedLens_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): AnIndexedLens_[J, S, T, C, D] = new AnIndexedLens_[J, S, T, C, D] { final def apply(indexed: Indexed[Shop[(C, J), D, *, *], J, C, D]): Shop[(C, J), D, S, T] = Shop(other.view _ compose Tuple2._1[A, I] compose self.view, s => d => self.set(other.set(d)(self.view(s)._1))(s)) } /** compose an [[AnIndexedLens_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): AnIndexedLens_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): AnIndexedLens_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[AnIndexedLens_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def composeWithLeftIndex[C, D](other: AnIndexedLens_[_, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = new AnIndexedLens_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: AnIndexedLens_[_, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = new AnIndexedLens_[I, S, T, C, D] { final def apply(indexed: Indexed[Shop[(C, I), D, *, *], I, C, D]): Shop[(C, I), D, S, T] = Shop(self.view(_).leftMap(other.view(_)._1), s => d => self.set(other.set(d)(self.view(s)._1))(s)) } /** compose an [[AnIndexedLens_]] with an [[AnIndexedLens_]], while preserving self indices */ - final def <<*[C, D](other: AnIndexedLens_[_, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: AnIndexedLens_[_, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose an [[AnIndexedLens_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = + final def andThenWithRightIndex[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[J, S, T, C, D] { override def apply[F[_]](f: ((C, J)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, _) => other.overF(f)(a) } }) /** compose an [[AnIndexedLens_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[AnIndexedLens_]] with an [[IndexedTraversal_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + final def andThenWithLeftIndex[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.overF { case (c, _) => f((c, i)) }(a) } }) /** compose an [[AnIndexedLens_]] with an [[IndexedTraversal_]], while preserving self indices */ - final def <<*[J, C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[J, C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose an [[AnIndexedLens_]] with an [[IndexedSetter_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, J, C, D]): S => T = s => self.set(other.over(indexed.runIndex)(self.view(s)._1))(s) } /** compose an [[AnIndexedLens_]] with an [[IndexedSetter_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[AnIndexedLens_]] with an [[IndexedSetter_]], while preserving self indices */ - final def composeWithLeftIndex[J, C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + final def andThenWithLeftIndex[J, C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = s => { val (a, i) = self.view(s) @@ -338,43 +338,43 @@ abstract class AnIndexedLens_[I, S, T, A, B] { self => } /** compose an [[AnIndexedLens_]] with an [[IndexedSetter_]], while preserving self indices */ - final def <<*[J, C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[J, C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose an [[AnIndexedLens_]] with an [[IndexedGetter_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = new IndexedGetter_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = new IndexedGetter_[J, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[Forget[(C, J), *, *], J, C, D]): Forget[(C, J), S, T] = Forget(other.view _ compose Tuple2._1[A, I] compose self.view) } /** compose an [[AnIndexedLens_]] with an [[IndexedGetter_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[AnIndexedLens_]] with an [[IndexedGetter_]], while preserving self indices */ - final def composeWithLeftIndex[J, C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { + final def andThenWithLeftIndex[J, C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[Forget[(C, I), *, *], I, C, D]): Forget[(C, I), S, T] = Forget(s => self.view(s).leftMap(other.view(_)._1)) } /** compose an [[AnIndexedLens_]] with an [[IndexedGetter_]], while preserving self indices */ - final def <<*[J, C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[J, C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose an [[AnIndexedLens_]] with an [[IndexedFold_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], J, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s)._1)(indexed.runIndex.runForget)) } /** compose an [[AnIndexedLens_]] with an [[IndexedFold_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[AnIndexedLens_]] with an [[IndexedFold_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s)._1) { case (c, _) => indexed.runIndex.runForget((c, self.view(s)._2)) }) } /** compose an [[AnIndexedLens_]] with an [[IndexedFold_]], while preserving self indices */ - final def <<*[J, C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[J, C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = andThenWithLeftIndex(other) } object AnIndexedLens_ { diff --git a/core/shared/src/main/scala/proptics/AnIso.scala b/core/shared/src/main/scala/proptics/AnIso.scala index 89f74f339..ea1720d5b 100644 --- a/core/shared/src/main/scala/proptics/AnIso.scala +++ b/core/shared/src/main/scala/proptics/AnIso.scala @@ -110,19 +110,19 @@ abstract class AnIso_[S, T, A, B] { self => /** transform an [[AnIso_]] to an [[Iso_]] */ final def asIso: Iso_[S, T, A, B] = self.withIso(Iso_[S, T, A, B]) - /** compose this [[AnIso_]] with a function lifted to a [[Getter_]], having this [[AnIso_]] applied last */ - final def to[C, D](f: A => C): Getter_[S, T, C, D] = compose(Getter_[A, B, C, D](f)) + /** compose this [[AnIso_]] with a function lifted to a [[Getter_]], having this [[AnIso_]] applied first */ + final def to[C, D](f: A => C): Getter_[S, T, C, D] = andThen(Getter_[A, B, C, D](f)) - /** compose this [[AnIso_]] with an [[Iso_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): AnIso_[S, T, C, D] = new AnIso_[S, T, C, D] { + /** compose this [[AnIso_]] with an [[Iso_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): AnIso_[S, T, C, D] = new AnIso_[S, T, C, D] { override private[proptics] def apply(exchange: Exchange[C, D, C, D]): Exchange[C, D, S, T] = - self.toExchange compose other(exchange) + self.toExchange andThen other(exchange) override def review(d: D): T = self.review(other.review(d)) } - /** compose this [[AnIso_]] with an [[Iso_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): AnIso_[C, D, A, B] = new AnIso_[C, D, A, B] { + /** compose this [[AnIso_]] with an [[Iso_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): AnIso_[C, D, A, B] = new AnIso_[C, D, A, B] { override private[proptics] def apply(exchange: Exchange[A, B, A, B]): Exchange[A, B, C, D] = Exchange(exchange.view compose self.view compose other.view, other.review _ compose self.review compose exchange.review) @@ -130,16 +130,16 @@ abstract class AnIso_[S, T, A, B] { self => override def review(b: B): D = other.review(self.review(b)) } - /** compose this [[AnIso_]] with an [[AnIso_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): AnIso_[S, T, C, D] = new AnIso_[S, T, C, D] { + /** compose this [[AnIso_]] with an [[AnIso_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): AnIso_[S, T, C, D] = new AnIso_[S, T, C, D] { override private[proptics] def apply(exchange: Exchange[C, D, C, D]): Exchange[C, D, S, T] = - self.toExchange compose other(exchange) + self.toExchange andThen other(exchange) override def review(d: D): T = self.review(other.review(d)) } - /** compose this [[AnIso_]] with an [[AnIso_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): AnIso_[C, D, A, B] = new AnIso_[C, D, A, B] { + /** compose this [[AnIso_]] with an [[AnIso_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): AnIso_[C, D, A, B] = new AnIso_[C, D, A, B] { override private[proptics] def apply(exchange: Exchange[A, B, A, B]): Exchange[A, B, C, D] = Exchange(exchange.view compose self.view compose other.view, other.review _ compose self.review compose exchange.review) @@ -147,28 +147,28 @@ abstract class AnIso_[S, T, A, B] { self => override def review(b: B): D = other.review(self.review(b)) } - /** compose this [[AnIso_]] with a [[Lens_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): Lens_[S, T, C, D] = new Lens_[S, T, C, D] { + /** compose this [[AnIso_]] with a [[Lens_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): Lens_[S, T, C, D] = new Lens_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev: Strong[P]): P[S, T] = ev.dimap(other(pab))(self.view)(self.review) } - /** compose this [[AnIso_]] with a [[Lens_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): Lens_[C, D, A, B] = + /** compose this [[AnIso_]] with a [[Lens_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): Lens_[C, D, A, B] = Lens_(self.view _ compose other.view)(c => b => other.set(self.review(b))(c)) - /** compose this [[AnIso_]] with an [[ALens_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): ALens_[S, T, C, D] = new ALens_[S, T, C, D] { + /** compose this [[AnIso_]] with an [[ALens_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): ALens_[S, T, C, D] = new ALens_[S, T, C, D] { override def apply(shop: Shop[C, D, C, D]): Shop[C, D, S, T] = Shop(shop.view compose other.view compose self.view, s => d => self.over(other(shop).set(_)(d))(s)) } - /** compose this [[AnIso_]] with an [[ALens_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): ALens_[C, D, A, B] = + /** compose this [[AnIso_]] with an [[ALens_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): ALens_[C, D, A, B] = ALens_(self.view _ compose other.view)(c => b => other.set(self.review(b))(c)) - /** compose this [[AnIso_]] with a [[Prism_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): Prism_[S, T, C, D] = new Prism_[S, T, C, D] { + /** compose this [[AnIso_]] with a [[Prism_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): Prism_[S, T, C, D] = new Prism_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev: Choice[P]): P[S, T] = ev.dimap(other(pab))(self.view)(self.review) @@ -176,29 +176,29 @@ abstract class AnIso_[S, T, A, B] { self => override def viewOrModify(s: S): Either[T, C] = other.viewOrModify(self.view(s)).leftMap(self.set(_)(s)) } - /** compose this [[AnIso_]] with a [[Prism_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): Prism_[C, D, A, B] = + /** compose this [[AnIso_]] with a [[Prism_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): Prism_[C, D, A, B] = Prism_((c: C) => other.viewOrModify(c).map(self.view))(other.review _ compose self.review) - /** compose this [[AnIso_]] with an [[APrism_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): APrism_[S, T, C, D] = new APrism_[S, T, C, D] { + /** compose this [[AnIso_]] with an [[APrism_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): APrism_[S, T, C, D] = new APrism_[S, T, C, D] { override private[proptics] def apply(market: Market[C, D, C, D]): Market[C, D, S, T] = { val exchange: Exchange[A, B, S, T] = toExchange val marketFromExchange = Market(Right[T, A] _ compose exchange.view, exchange.review) - marketFromExchange compose other(market) + marketFromExchange andThen other(market) } override def traverse[F[_]](s: S)(f: C => F[D])(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(f)) } - /** compose this [[AnIso_]] with an [[APrism_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): APrism_[C, D, A, B] = + /** compose this [[AnIso_]] with an [[APrism_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): APrism_[C, D, A, B] = APrism_((c: C) => other.viewOrModify(c).map(self.view))(other.review _ compose self.review) - /** compose this [[AnIso_]] with an [[AffineTraversal_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { + /** compose this [[AnIso_]] with an [[AffineTraversal_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev0: Choice[P], ev1: Strong[P]): P[S, T] = ev0.dimap(other(pab))(self.view)(self.review) @@ -206,12 +206,12 @@ abstract class AnIso_[S, T, A, B] { self => override def viewOrModify(s: S): Either[T, C] = other.viewOrModify(self.view(s)).leftMap(review) } - /** compose this [[AnIso_]] with an [[AffineTraversal_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = + /** compose this [[AnIso_]] with an [[AffineTraversal_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = AffineTraversal_((c: C) => other.viewOrModify(c).map(self.view))(c => b => other.set(self.review(b))(c)) - /** compose this [[AnIso_]] with an [[AnAffineTraversal_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = new AnAffineTraversal_[S, T, C, D] { + /** compose this [[AnIso_]] with an [[AnAffineTraversal_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = new AnAffineTraversal_[S, T, C, D] { override private[proptics] def apply(pab: Stall[C, D, C, D]): Stall[C, D, S, T] = Stall(s => other.viewOrModify(self.view(s)).leftMap(self.review), s => d => self.set(other.set(d)(self.view(s)))(s)) @@ -219,156 +219,156 @@ abstract class AnIso_[S, T, A, B] { self => override def viewOrModify(s: S): Either[T, C] = other.viewOrModify(self.view(s)).leftMap(review) } - /** compose this [[AnIso_]] with an [[AnAffineTraversal_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[AnIso_]] with an [[AnAffineTraversal_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_((c: C) => other.viewOrModify(c).map(self.view))(c => b => other.set(self.review(b))(c)) - /** compose this [[AnIso_]] with a [[Traversal_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { + /** compose this [[AnIso_]] with a [[Traversal_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev: Wander[P]): P[S, T] = ev.dimap(other(pab))(self.view)(self.review) } - /** compose this [[AnIso_]] with a [[Traversal_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = + /** compose this [[AnIso_]] with a [[Traversal_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = Traversal_.wander(new LensLike[C, D, A, B] { override def apply[F[_]](f: A => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF(f)) }) - /** compose this [[AnIso_]] with an [[ATraversal_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[AnIso_]] with an [[ATraversal_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.overF(pafb)) }) - /** compose this [[AnIso_]] with an [[ATraversal_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[AnIso_]] with an [[ATraversal_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[AnIso_]] with a [[Setter_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[AnIso_]] with a [[Setter_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self.over(other(pab)) } - /** compose this [[AnIso_]] with a [[Setter_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[AnIso_]] with a [[Setter_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other(self.over(pab)) } - /** compose this [[AnIso_]] with a [[Getter_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { + /** compose this [[AnIso_]] with a [[Getter_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { override private[proptics] def apply(forget: Forget[C, C, D]): Forget[C, S, T] = Forget(forget.runForget compose other.view compose self.view) } - /** compose this [[AnIso_]] with a [[Getter_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { + /** compose this [[AnIso_]] with a [[Getter_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { override private[proptics] def apply(forget: Forget[A, A, B]): Forget[A, C, D] = Forget(self.view _ compose other.view) } - /** compose this [[AnIso_]] with a [[Fold_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[AnIso_]] with a [[Fold_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s))(forget.runForget)) } - /** compose this [[AnIso_]] with a [[Fold_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[AnIso_]] with a [[Fold_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(forget.runForget compose self.view)) } - /** compose this [[AnIso_]] with a [[Grate_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: Grate_[A, B, C, D]): Grate_[S, T, C, D] = new Grate_[S, T, C, D] { + /** compose this [[AnIso_]] with a [[Grate_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: Grate_[A, B, C, D]): Grate_[S, T, C, D] = new Grate_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Closed[P]): P[S, T] = ev.dimap(other(pab))(self.view)(self.review) } - /** compose this [[AnIso_]] with a [[Grate_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: Grate_[C, D, S, T]): Grate_[C, D, A, B] = new Grate_[C, D, A, B] { + /** compose this [[AnIso_]] with a [[Grate_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: Grate_[C, D, S, T]): Grate_[C, D, A, B] = new Grate_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Closed[P]): P[C, D] = other(ev.dimap(pab)(self.view)(self.review)) } - /** compose this [[AnIso_]] with a [[Review_]], having this [[AnIso_]] applied last */ - final def compose[C, D](other: Review_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { + /** compose this [[AnIso_]] with a [[Review_]], having this [[AnIso_]] applied first */ + final def andThen[C, D](other: Review_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { override private[proptics] def apply(tagged: Tagged[C, D]): Tagged[S, T] = Tagged(self.review(other.review(tagged.runTag))) } - /** compose this [[AnIso_]] with a [[Review_]], having this [[AnIso_]] applied first */ - final def andThen[C, D](other: Review_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { + /** compose this [[AnIso_]] with a [[Review_]], having this [[AnIso_]] applied last */ + final def compose[C, D](other: Review_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { override private[proptics] def apply(tagged: Tagged[A, B]): Tagged[C, D] = Tagged(other.review(self.review(tagged.runTag))) } - /** compose this [[AnIso_]] with an [[IndexedLens_]], having this [[AnIso_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedLens_[I, S, T, C, D] = + /** compose this [[AnIso_]] with an [[IndexedLens_]], having this [[AnIso_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedLens_[I, S, T, C, D] = IndexedLens_((s: S) => other.view(self.view(s)))(s => d => self.set(other.set(d)(self.view(s)))(s)) - /** compose this [[AnIso_]] with an [[IndexedLens_]], having this [[AnIso_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedLens_[I, C, D, A, B] = + /** compose this [[AnIso_]] with an [[IndexedLens_]], having this [[AnIso_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedLens_[I, C, D, A, B] = IndexedLens_((c: C) => other.view(c).leftMap(self.view))(c => b => other.over { case (s, _) => self.set(b)(s) }(c)) - /** compose this [[AnIso_]] with an [[AnIndexedLens_]], having this [[AnIso_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = + /** compose this [[AnIso_]] with an [[AnIndexedLens_]], having this [[AnIso_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = AnIndexedLens_((s: S) => other.view(self.view(s)))(s => d => self.set(other.set(d)(self.view(s)))(s)) - /** compose this [[AnIso_]] with an [[AnIndexedLens_]], having this [[AnIso_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = + /** compose this [[AnIso_]] with an [[AnIndexedLens_]], having this [[AnIso_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = AnIndexedLens_((c: C) => other.view(c).leftMap(self.view))(c => b => other.over { case (s, _) => self.set(b)(s) }(c)) - /** compose this [[AnIso_]] with an [[IndexedTraversal_]], having this [[AnIso_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[AnIso_]] with an [[IndexedTraversal_]], having this [[AnIso_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[AnIso_]] with an [[IndexedTraversal_]], having this [[AnIso_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[AnIso_]] with an [[IndexedTraversal_]], having this [[AnIso_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[AnIso_]] with an [[IndexedSetter_]], having this [[AnIso_]] applied last */ - final def compose[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[AnIso_]] with an [[IndexedSetter_]], having this [[AnIso_]] applied first */ + final def andThen[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over(other.over(indexed.runIndex)) } - /** compose this [[AnIso_]] with an [[IndexedSetter_]], having this [[AnIso_]] applied first */ - final def andThen[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[AnIso_]] with an [[IndexedSetter_]], having this [[AnIso_]] applied last */ + final def compose[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[Function, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[AnIso_]] with an [[IndexedGetter_]], having this [[AnIso_]] applied last */ - final def compose[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[AnIso_]] with an [[IndexedGetter_]], having this [[AnIso_]] applied first */ + final def andThen[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(indexed.runIndex.runForget compose other.view compose self.view) } - /** compose this [[AnIso_]] with an [[IndexedGetter_]], having this [[AnIso_]] applied first */ - final def andThen[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[AnIso_]] with an [[IndexedGetter_]], having this [[AnIso_]] applied last */ + final def compose[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(c => indexed.runIndex.runForget(other.view(c).leftMap(self.view))) } - /** compose this [[AnIso_]] with an [[IndexedFold_]], having this [[AnIso_]] applied last */ - final def compose[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[AnIso_]] with an [[IndexedFold_]], having this [[AnIso_]] applied first */ + final def andThen[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s))(indexed.runIndex.runForget)) } - /** compose this [[AnIso_]] with an [[IndexedFold_]], having this [[AnIso_]] applied first */ - final def andThen[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[AnIso_]] with an [[IndexedFold_]], having this [[AnIso_]] applied last */ + final def compose[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => indexed.runIndex.runForget((self.view(s), i)) }) } diff --git a/core/shared/src/main/scala/proptics/Fold.scala b/core/shared/src/main/scala/proptics/Fold.scala index 19756a401..61758c870 100644 --- a/core/shared/src/main/scala/proptics/Fold.scala +++ b/core/shared/src/main/scala/proptics/Fold.scala @@ -133,156 +133,156 @@ abstract class Fold_[S, T, A, B] extends Serializable { self => } }) - /** compose this [[Fold_]] with a function lifted to a [[Getter_]], having this [[Fold_]] applied last */ - final def to[C, D](f: A => C): Fold_[S, T, C, D] = compose(Getter_[A, B, C, D](f)) + /** compose this [[Fold_]] with a function lifted to a [[Getter_]], having this [[Fold_]] applied first */ + final def to[C, D](f: A => C): Fold_[S, T, C, D] = andThen(Getter_[A, B, C, D](f)) - /** compose this [[Fold_]] with an [[Iso_]], having this [[Fold_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Fold_]] with an [[Iso_]], having this [[Fold_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = self(other(forget)(Forget.profunctorForget)) } - /** compose this [[Fold_]] with an [[Iso_]], having this [[Fold_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Fold_]] with an [[Iso_]], having this [[Fold_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c))(forget.runForget)) } - /** compose this [[Fold_]] with an [[AnIso_]], having this [[Fold_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Fold_]] with an [[AnIso_]], having this [[Fold_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(forget.runForget compose other.view)) } - /** compose this [[Fold_]] with an [[AnIso_]], having this [[Fold_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Fold_]] with an [[AnIso_]], having this [[Fold_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c))(forget.runForget)) } - /** compose this [[Fold_]] with a [[Lens_]], having this [[Fold_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Fold_]] with a [[Lens_]], having this [[Fold_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = self(other(forget)) } - /** compose this [[Fold_]] with a [[Lens_]], having this [[Fold_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Fold_]] with a [[Lens_]], having this [[Fold_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c))(forget.runForget)) } - /** compose this [[Fold_]] with an [[ALens_]], having this [[Fold_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Fold_]] with an [[ALens_]], having this [[Fold_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(forget.runForget compose other.view)) } - /** compose this [[Fold_]] with an [[ALens_]], having this [[Fold_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Fold_]] with an [[ALens_]], having this [[Fold_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c))(forget.runForget)) } - /** compose this [[Fold_]] with a [[Prism_]], having this [[Fold_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Fold_]] with a [[Prism_]], having this [[Fold_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = self(other(forget)) } - /** compose this [[Fold_]] with a [[Prism_]], having this [[Fold_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Fold_]] with a [[Prism_]], having this [[Fold_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.preview(_).fold(Monoid[R].empty)(self.foldMap(_)(forget.runForget))) } - /** compose this [[Fold_]] with an [[APrism_]], having this [[Fold_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Fold_]] with an [[APrism_]], having this [[Fold_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.viewOrModify(_).fold(const(Monoid[R].empty), forget.runForget))) } - /** compose this [[Fold_]] with an [[APrism_]], having this [[Fold_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Fold_]] with an [[APrism_]], having this [[Fold_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.preview(_).fold(Monoid[R].empty)(self.foldMap(_)(forget.runForget))) } - /** compose this [[Fold_]] with a [[AffineTraversal_]], having this [[Fold_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Fold_]] with a [[AffineTraversal_]], having this [[Fold_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = self(other(forget)) } - /** compose this [[Fold_]] with a [[AffineTraversal_]], having this [[Fold_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Fold_]] with a [[AffineTraversal_]], having this [[Fold_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.preview(_).fold(Monoid[R].empty)(self.foldMap(_)(forget.runForget))) } - /** compose this [[Fold_]] with a [[AnAffineTraversal_]], having this [[Fold_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Fold_]] with a [[AnAffineTraversal_]], having this [[Fold_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.viewOrModify(_).fold(const(Monoid.empty[R]), forget.runForget))) } - /** compose this [[Fold_]] with a [[AnAffineTraversal_]], having this [[Fold_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Fold_]] with a [[AnAffineTraversal_]], having this [[Fold_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.preview(_).fold(Monoid[R].empty)(self.foldMap(_)(forget.runForget))) } - /** compose this [[Fold_]] with a [[Traversal_]], having this [[Fold_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Fold_]] with a [[Traversal_]], having this [[Fold_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = self(other(forget)) } - /** compose this [[Fold_]] with a [[Traversal_]], having this [[Fold_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Fold_]] with a [[Traversal_]], having this [[Fold_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(self.foldMap(_)(forget.runForget))) } - /** compose this [[Fold_]] with an [[ATraversal_]], having this [[Fold_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Fold_]] with an [[ATraversal_]], having this [[Fold_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.foldMap(_)(forget.runForget))) } - /** compose this [[Fold_]] with an [[ATraversal_]], having this [[Fold_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Fold_]] with an [[ATraversal_]], having this [[Fold_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(self.foldMap(_)(forget.runForget))) } - /** compose this [[Fold_]] with a [[Getter_]], having this [[Fold_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Fold_]] with a [[Getter_]], having this [[Fold_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(forget.runForget compose other.view)) } - /** compose this [[Fold_]] with a [[Getter_]], having this [[Fold_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Fold_]] with a [[Getter_]], having this [[Fold_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c))(forget.runForget)) } - /** compose this [[Fold_]] with a [[Fold_]], having this [[Fold_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Fold_]] with a [[Fold_]], having this [[Fold_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = self(other(forget)) } - /** compose this [[Fold_]] with a [[Fold_]], having this [[Fold_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Fold_]] with a [[Fold_]], having this [[Fold_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(self.foldMap(_)(forget.runForget))) } - /** compose this [[Fold_]] with an [[IndexedLens_]], having this [[Fold_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Fold_]] with an [[IndexedLens_]], having this [[Fold_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(indexed.runIndex.runForget compose other.view)) } - /** compose this [[Fold_]] with an [[IndexedLens_]], having this [[Fold_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Fold_]] with an [[IndexedLens_]], having this [[Fold_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => val (s, i) = other.view(c) @@ -290,14 +290,14 @@ abstract class Fold_[S, T, A, B] extends Serializable { self => } } - /** compose this [[Fold_]] with an [[AnIndexedLens_]], having this [[Fold_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Fold_]] with an [[AnIndexedLens_]], having this [[Fold_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(indexed.runIndex.runForget compose other.view)) } - /** compose this [[Fold_]] with an [[AnIndexedLens_]], having this [[Fold_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Fold_]] with an [[AnIndexedLens_]], having this [[Fold_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => val (s, i) = other.view(c) @@ -305,26 +305,26 @@ abstract class Fold_[S, T, A, B] extends Serializable { self => } } - /** compose this [[Fold_]] with an [[IndexedTraversal_]], having this [[Fold_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Fold_]] with an [[IndexedTraversal_]], having this [[Fold_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.foldMap(_)(indexed.runIndex.runForget))) } - /** compose this [[Fold_]] with an [[IndexedTraversal_]], having this [[Fold_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Fold_]] with an [[IndexedTraversal_]], having this [[Fold_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => self.foldMap(s)(a => indexed.runIndex.runForget((a, i))) }) } - /** compose this [[Fold_]] with an [[IndexedGetter_]], having this [[Fold_]] applied last */ - final def compose[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Fold_]] with an [[IndexedGetter_]], having this [[Fold_]] applied first */ + final def andThen[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(indexed.runIndex.runForget compose other.view)) } - /** compose this [[Fold_]] with an [[IndexedGetter_]], having this [[Fold_]] applied first */ - final def andThen[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Fold_]] with an [[IndexedGetter_]], having this [[Fold_]] applied last */ + final def compose[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => val (s, i) = other.view(c) @@ -332,14 +332,14 @@ abstract class Fold_[S, T, A, B] extends Serializable { self => } } - /** compose this [[Fold_]] with an [[IndexedFold_]], having this [[Fold_]] applied last */ - final def compose[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Fold_]] with an [[IndexedFold_]], having this [[Fold_]] applied first */ + final def andThen[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.foldMap(_)(indexed.runIndex.runForget))) } - /** compose this [[Fold_]] with an [[IndexedFold_]], having this [[Fold_]] applied first */ - final def andThen[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Fold_]] with an [[IndexedFold_]], having this [[Fold_]] applied last */ + final def compose[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => self.foldMap(s)(a => indexed.runIndex.runForget((a, i))) }) } diff --git a/core/shared/src/main/scala/proptics/Getter.scala b/core/shared/src/main/scala/proptics/Getter.scala index 34d46be52..22b84fba5 100644 --- a/core/shared/src/main/scala/proptics/Getter.scala +++ b/core/shared/src/main/scala/proptics/Getter.scala @@ -43,7 +43,7 @@ abstract class Getter_[S, T, A, B] extends Serializable { self => final def use(implicit ev: State[S, A]): State[S, A] = ev.inspect(view) /** compose this [[Getter_]] with a function lifted to a [[Getter_]] */ - final def to[C, D](f: A => C): Getter_[S, T, C, D] = compose(Getter_[A, B, C, D](f)) + final def to[C, D](f: A => C): Getter_[S, T, C, D] = andThen(Getter_[A, B, C, D](f)) /** transform a [[Getter_]] to a [[Fold_]] */ final def asFold: Fold_[S, T, A, B] = new Fold_[S, T, A, B] { @@ -51,158 +51,158 @@ abstract class Getter_[S, T, A, B] extends Serializable { self => Forget(forget.runForget compose self.view) } - /** compose this [[Getter_]] with an [[Iso_]], having this [[Getter_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { + /** compose this [[Getter_]] with an [[Iso_]], having this [[Getter_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { override private[proptics] def apply(forget: Forget[C, C, D]): Forget[C, S, T] = Forget(forget.runForget compose other.view compose self.view) } - /** compose this [[Getter_]] with an [[Iso_]], having this [[Getter_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { + /** compose this [[Getter_]] with an [[Iso_]], having this [[Getter_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { override private[proptics] def apply(forget: Forget[A, A, B]): Forget[A, C, D] = Forget(forget.runForget compose self.view compose other.view) } - /** compose this [[Getter_]] with an [[AnIso_]], having this [[Getter_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { + /** compose this [[Getter_]] with an [[AnIso_]], having this [[Getter_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { override private[proptics] def apply(forget: Forget[C, C, D]): Forget[C, S, T] = Forget(forget.runForget compose other.view compose self.view) } - /** compose this [[Getter_]] with an [[AnIso_]], having this [[Getter_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { + /** compose this [[Getter_]] with an [[AnIso_]], having this [[Getter_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { override private[proptics] def apply(forget: Forget[A, A, B]): Forget[A, C, D] = Forget(forget.runForget compose self.view compose other.view) } - /** compose this [[Getter_]] with a [[Lens_]], having this [[Getter_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { + /** compose this [[Getter_]] with a [[Lens_]], having this [[Getter_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { override private[proptics] def apply(forget: Forget[C, C, D]): Forget[C, S, T] = Forget(forget.runForget compose other.view compose self.view) } - /** compose this [[Getter_]] with a [[Lens_]], having this [[Getter_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { + /** compose this [[Getter_]] with a [[Lens_]], having this [[Getter_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { override private[proptics] def apply(forget: Forget[A, A, B]): Forget[A, C, D] = Forget(forget.runForget compose self.view compose other.view) } - /** compose this [[Getter_]] with an [[ALens_]], having this [[Getter_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { + /** compose this [[Getter_]] with an [[ALens_]], having this [[Getter_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { override private[proptics] def apply(forget: Forget[C, C, D]): Forget[C, S, T] = Forget(forget.runForget compose other.view compose self.view) } - /** compose this [[Getter_]] with an [[ALens_]], having this [[Getter_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { + /** compose this [[Getter_]] with an [[ALens_]], having this [[Getter_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { override private[proptics] def apply(forget: Forget[A, A, B]): Forget[A, C, D] = Forget(forget.runForget compose self.view compose other.view) } - /** compose this [[Getter_]] with a [[Prism_]], having this [[Getter_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Getter_]] with a [[Prism_]], having this [[Getter_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(s => other.preview(self.view(s)).fold(Monoid[R].empty)(forget.runForget)) } - /** compose this [[Getter_]] with a [[Prism_]], having this [[Getter_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Getter_]] with a [[Prism_]], having this [[Getter_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.viewOrModify(_).fold(const(Monoid[R].empty), forget.runForget compose self.view)) } - /** compose this [[Getter_]] with an [[APrism_]], having this [[Getter_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Getter_]] with an [[APrism_]], having this [[Getter_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(s => other.preview(self.view(s)).fold(Monoid[R].empty)(forget.runForget)) } - /** compose this [[Getter_]] with an [[APrism_]], having this [[Getter_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Getter_]] with an [[APrism_]], having this [[Getter_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.viewOrModify(_).fold(const(Monoid[R].empty), forget.runForget compose self.view)) } - /** compose this [[Getter_]] with an [[AffineTraversal_]], having this [[Getter_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Getter_]] with an [[AffineTraversal_]], having this [[Getter_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(s => other.preview(self.view(s)).fold(Monoid[R].empty)(forget.runForget)) } - /** compose this [[Getter_]] with an [[AffineTraversal_]], having this [[Getter_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Getter_]] with an [[AffineTraversal_]], having this [[Getter_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.viewOrModify(_).fold(const(Monoid[R].empty), forget.runForget compose self.view)) } - /** compose this [[Getter_]] with an [[AnAffineTraversal_]], having this [[Getter_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Getter_]] with an [[AnAffineTraversal_]], having this [[Getter_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(s => other.preview(self.view(s)).fold(Monoid[R].empty)(forget.runForget)) } - /** compose this [[Getter_]] with an [[AnAffineTraversal_]], having this [[Getter_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Getter_]] with an [[AnAffineTraversal_]], having this [[Getter_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.viewOrModify(_).fold(const(Monoid[R].empty), forget.runForget compose self.view)) } - /** compose this [[Getter_]] with a [[Traversal_]], having this [[Getter_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Getter_]] with a [[Traversal_]], having this [[Getter_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s))(forget.runForget)) } - /** compose this [[Getter_]] with a [[Traversal_]], having this [[Getter_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Getter_]] with a [[Traversal_]], having this [[Getter_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(forget.runForget compose self.view)) } - /** compose this [[Getter_]] with an [[ATraversal_]], having this [[Getter_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Getter_]] with an [[ATraversal_]], having this [[Getter_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s))(forget.runForget)) } - /** compose this [[Getter_]] with an [[ATraversal_]], having this [[Getter_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Getter_]] with an [[ATraversal_]], having this [[Getter_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(forget.runForget compose self.view)) } - /** compose this [[Getter_]] with a [[Getter_]], having this [[Getter_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { + /** compose this [[Getter_]] with a [[Getter_]], having this [[Getter_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { override private[proptics] def apply(forget: Forget[C, C, D]): Forget[C, S, T] = Forget(forget.runForget compose other.view compose self.view) } - /** compose this [[Getter_]] with a [[Getter_]], having this [[Getter_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { + /** compose this [[Getter_]] with a [[Getter_]], having this [[Getter_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { override private[proptics] def apply(forget: Forget[A, A, B]): Forget[A, C, D] = Forget(forget.runForget compose self.view compose other.view) } - /** compose this [[Getter_]] with a [[Fold_]], having this [[Getter_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Getter_]] with a [[Fold_]], having this [[Getter_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s))(forget.runForget)) } - /** compose this [[Getter_]] with a [[Fold_]], having this [[Getter_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Getter_]] with a [[Fold_]], having this [[Getter_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(forget.runForget compose self.view)) } - /** compose this [[Getter_]] with an [[IndexedLens_]], having this [[Getter_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { + /** compose this [[Getter_]] with an [[IndexedLens_]], having this [[Getter_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { private[proptics] def apply(indexed: Indexed[Forget[(C, I), *, *], I, C, D]): Forget[(C, I), S, T] = Forget(indexed.runIndex.runForget compose other.view compose self.view) } - /** compose this [[Getter_]] with an [[IndexedLens_]], having this [[Getter_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedGetter_[I, C, D, A, B] = new IndexedGetter_[I, C, D, A, B] { + /** compose this [[Getter_]] with an [[IndexedLens_]], having this [[Getter_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedGetter_[I, C, D, A, B] = new IndexedGetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[Forget[(A, I), *, *], I, A, B]): Forget[(A, I), C, D] = Forget { c => val (s, i) = other.view(c) @@ -210,14 +210,14 @@ abstract class Getter_[S, T, A, B] extends Serializable { self => } } - /** compose this [[Getter_]] with an [[AnIndexedLens_]], having this [[Getter_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { + /** compose this [[Getter_]] with an [[AnIndexedLens_]], having this [[Getter_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { private[proptics] def apply(indexed: Indexed[Forget[(C, I), *, *], I, C, D]): Forget[(C, I), S, T] = Forget(indexed.runIndex.runForget compose other.view compose self.view) } - /** compose this [[Getter_]] with an [[AnIndexedLens_]], having this [[Getter_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedGetter_[I, C, D, A, B] = new IndexedGetter_[I, C, D, A, B] { + /** compose this [[Getter_]] with an [[AnIndexedLens_]], having this [[Getter_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedGetter_[I, C, D, A, B] = new IndexedGetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[Forget[(A, I), *, *], I, A, B]): Forget[(A, I), C, D] = Forget { c => val (s, i) = other.view(c) @@ -225,26 +225,26 @@ abstract class Getter_[S, T, A, B] extends Serializable { self => } } - /** compose this [[Getter_]] with an [[IndexedTraversal_]], having this [[Getter_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Getter_]] with an [[IndexedTraversal_]], having this [[Getter_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s))(indexed.runIndex.runForget)) } - /** compose this [[Getter_]] with an [[IndexedTraversal_]], having this [[Getter_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Getter_]] with an [[IndexedTraversal_]], having this [[Getter_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => indexed.runIndex.runForget((self.view(s), i)) }) } - /** compose this [[Getter_]] with an [[IndexedGetter_]], having this [[Getter_]] applied last */ - final def compose[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Getter_]] with an [[IndexedGetter_]], having this [[Getter_]] applied first */ + final def andThen[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(indexed.runIndex.runForget compose other.view compose self.view) } - /** compose this [[Getter_]] with an [[IndexedGetter_]], having this [[Getter_]] applied first */ - final def andThen[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Getter_]] with an [[IndexedGetter_]], having this [[Getter_]] applied last */ + final def compose[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => val (s, i) = other.view(c) @@ -252,14 +252,14 @@ abstract class Getter_[S, T, A, B] extends Serializable { self => } } - /** compose this [[Getter_]] with an [[IndexedFold_]], having this [[Getter_]] applied last */ - final def compose[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Getter_]] with an [[IndexedFold_]], having this [[Getter_]] applied first */ + final def andThen[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s))(indexed.runIndex.runForget)) } - /** compose this [[Getter_]] with an [[IndexedFold_]], having this [[Getter_]] applied first */ - final def andThen[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Getter_]] with an [[IndexedFold_]], having this [[Getter_]] applied last */ + final def compose[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => indexed.runIndex.runForget((self.view(s), i)) }) } diff --git a/core/shared/src/main/scala/proptics/Grate.scala b/core/shared/src/main/scala/proptics/Grate.scala index e5aa68a9c..345474da3 100644 --- a/core/shared/src/main/scala/proptics/Grate.scala +++ b/core/shared/src/main/scala/proptics/Grate.scala @@ -39,68 +39,68 @@ abstract class Grate_[S, T, A, B] { self => /** synonym for [[cotraverse]], flipped */ final def zipWithF[F[_]: Applicative](f: F[A] => B)(fs: F[S]): T = cotraverse(fs)(f) - /** compose this [[Grate_]] with an [[Iso_]], having this [[Grate_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): Grate_[S, T, C, D] = new Grate_[S, T, C, D] { + /** compose this [[Grate_]] with an [[Iso_]], having this [[Grate_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): Grate_[S, T, C, D] = new Grate_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Closed[P]): P[S, T] = self(other(pab)) } - /** compose this [[Grate_]] with an [[Iso_]], having this [[Grate_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): Grate_[C, D, A, B] = new Grate_[C, D, A, B] { + /** compose this [[Grate_]] with an [[Iso_]], having this [[Grate_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): Grate_[C, D, A, B] = new Grate_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Closed[P]): P[C, D] = other(self(pab)) } - /** compose this [[Grate_]] with an [[AnIso_]], having this [[Grate_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): Grate_[S, T, C, D] = new Grate_[S, T, C, D] { + /** compose this [[Grate_]] with an [[AnIso_]], having this [[Grate_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): Grate_[S, T, C, D] = new Grate_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Closed[P]): P[S, T] = self(ev.dimap(pab)(other.view)(other.review)) } - /** compose this [[Grate_]] with an [[AnIso_]], having this [[Grate_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): Grate_[C, D, A, B] = new Grate_[C, D, A, B] { + /** compose this [[Grate_]] with an [[AnIso_]], having this [[Grate_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): Grate_[C, D, A, B] = new Grate_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Closed[P]): P[C, D] = ev.dimap(self(pab))(other.view)(other.review) } - /** compose this [[Grate_]] with a [[Setter_]], having this [[Grate_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Grate_]] with a [[Setter_]], having this [[Grate_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[Grate_]] with a [[Setter_]], having this [[Grate_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Grate_]] with a [[Setter_]], having this [[Grate_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Grate_]] with a [[Grate_]], having this [[Grate_]] applied last */ - final def compose[C, D](other: Grate_[A, B, C, D]): Grate_[S, T, C, D] = new Grate_[S, T, C, D] { + /** compose this [[Grate_]] with a [[Grate_]], having this [[Grate_]] applied first */ + final def andThen[C, D](other: Grate_[A, B, C, D]): Grate_[S, T, C, D] = new Grate_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Closed[P]): P[S, T] = self(other(pab)) } - /** compose this [[Grate_]] with a [[Grate_]], having this [[Grate_]] applied first */ - final def andThen[C, D](other: Grate_[C, D, S, T]): Grate_[C, D, A, B] = new Grate_[C, D, A, B] { + /** compose this [[Grate_]] with a [[Grate_]], having this [[Grate_]] applied last */ + final def compose[C, D](other: Grate_[C, D, S, T]): Grate_[C, D, A, B] = new Grate_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Closed[P]): P[C, D] = other(self(pab)) } - /** compose this [[Grate_]] with a [[Review_]], having this [[Grate_]] applied last */ - final def compose[C, D](other: Review_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { + /** compose this [[Grate_]] with a [[Review_]], having this [[Grate_]] applied first */ + final def andThen[C, D](other: Review_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { override private[proptics] def apply(tagged: Tagged[C, D]): Tagged[S, T] = self(other(tagged)) } - /** compose this [[Grate_]] with a [[Review_]], having this [[Grate_]] applied first */ - final def andThen[C, D](other: Review_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { + /** compose this [[Grate_]] with a [[Review_]], having this [[Grate_]] applied last */ + final def compose[C, D](other: Review_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { override private[proptics] def apply(tagged: Tagged[A, B]): Tagged[C, D] = Tagged(other.review(self.review(tagged.runTag))) } - /** compose this [[Grate_]] with an [[IndexedSetter_]], having this [[Grate_]] applied last */ - final def compose[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[Grate_]] with an [[IndexedSetter_]], having this [[Grate_]] applied first */ + final def andThen[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over(other.over(indexed.runIndex)) } - /** compose this [[Grate_]] with an [[IndexedSetter_]], having this [[Grate_]] applied first */ - final def andThen[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[Grate_]] with an [[IndexedSetter_]], having this [[Grate_]] applied last */ + final def compose[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } diff --git a/core/shared/src/main/scala/proptics/IndexedFold.scala b/core/shared/src/main/scala/proptics/IndexedFold.scala index 3285be20f..d05ea3581 100644 --- a/core/shared/src/main/scala/proptics/IndexedFold.scala +++ b/core/shared/src/main/scala/proptics/IndexedFold.scala @@ -138,62 +138,62 @@ abstract class IndexedFold_[I, S, T, A, B] extends Serializable { self => Forget(self.foldMap(_)(forget.runForget compose Tuple2._1)) } - /** compose this [[IndexedFold_]] with an [[Iso_]], having this [[IndexedFold_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedFold_]] with an [[Iso_]], having this [[IndexedFold_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((other.view(a), i)) }) } - /** compose this [[IndexedFold_]] with an [[Iso_]], having this [[IndexedFold_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedFold_]] with an [[Iso_]], having this [[IndexedFold_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c)) { case (a, i) => indexed.runIndex.runForget((a, i)) }) } - /** compose this [[IndexedFold_]] with an [[AnIso_]], having this [[IndexedFold_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedFold_]] with an [[AnIso_]], having this [[IndexedFold_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((other.view(a), i)) }) } - /** compose this [[IndexedFold_]] with an [[AnIso_]], having this [[IndexedFold_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedFold_]] with an [[AnIso_]], having this [[IndexedFold_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c)) { case (a, i) => indexed.runIndex.runForget((a, i)) }) } - /** compose this [[IndexedFold_]] with an [[Lens_]], having this [[IndexedFold_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedFold_]] with an [[Lens_]], having this [[IndexedFold_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((other.view(a), i)) }) } - /** compose this [[IndexedFold_]] with an [[Lens_]], having this [[IndexedFold_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedFold_]] with an [[Lens_]], having this [[IndexedFold_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c)) { case (a, i) => indexed.runIndex.runForget((a, i)) }) } - /** compose this [[IndexedFold_]] with an [[ALens_]], having this [[IndexedFold_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedFold_]] with an [[ALens_]], having this [[IndexedFold_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((other.view(a), i)) }) } - /** compose this [[IndexedFold_]] with an [[ALens_]], having this [[IndexedFold_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedFold_]] with an [[ALens_]], having this [[IndexedFold_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c)) { case (a, i) => indexed.runIndex.runForget((a, i)) }) } - /** compose this [[IndexedFold_]] with an [[Prism_]], having this [[IndexedFold_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedFold_]] with an [[Prism_]], having this [[IndexedFold_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => other.preview(a).fold(Monoid[R].empty)(c => indexed.runIndex.runForget((c, i))) }) } - /** compose this [[IndexedFold_]] with an [[Prism_]], having this [[IndexedFold_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedFold_]] with an [[Prism_]], having this [[IndexedFold_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => other @@ -202,14 +202,14 @@ abstract class IndexedFold_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedFold_]] with an [[APrism_]], having this [[IndexedFold_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedFold_]] with an [[APrism_]], having this [[IndexedFold_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => other.preview(a).fold(Monoid[R].empty)(c => indexed.runIndex.runForget((c, i))) }) } - /** compose this [[IndexedFold_]] with an [[APrism_]], having this [[IndexedFold_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedFold_]] with an [[APrism_]], having this [[IndexedFold_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => other @@ -218,14 +218,14 @@ abstract class IndexedFold_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedFold_]] with an [[AffineTraversal_]], having this [[IndexedFold_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedFold_]] with an [[AffineTraversal_]], having this [[IndexedFold_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => other.preview(a).fold(Monoid[R].empty)(c => indexed.runIndex.runForget((c, i))) }) } - /** compose this [[IndexedFold_]] with an [[AffineTraversal_]], having this [[IndexedFold_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedFold_]] with an [[AffineTraversal_]], having this [[IndexedFold_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => other @@ -234,14 +234,14 @@ abstract class IndexedFold_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedFold_]] with an [[AffineTraversal_]], having this [[IndexedFold_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedFold_]] with an [[AffineTraversal_]], having this [[IndexedFold_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => other.preview(a).fold(Monoid[R].empty)(c => indexed.runIndex.runForget((c, i))) }) } - /** compose this [[IndexedFold_]] with an [[AffineTraversal_]], having this [[IndexedFold_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedFold_]] with an [[AffineTraversal_]], having this [[IndexedFold_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => other @@ -250,149 +250,149 @@ abstract class IndexedFold_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedFold_]] with an [[Traversal_]], having this [[IndexedFold_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedFold_]] with an [[Traversal_]], having this [[IndexedFold_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => other.preview(a).fold(Monoid[R].empty)(c => indexed.runIndex.runForget((c, i))) }) } - /** compose this [[IndexedFold_]] with an [[Traversal_]], having this [[IndexedFold_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedFold_]] with an [[Traversal_]], having this [[IndexedFold_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((a, i)) })) } - /** compose this [[IndexedFold_]] with an [[ATraversal_]], having this [[IndexedFold_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedFold_]] with an [[ATraversal_]], having this [[IndexedFold_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => other.preview(a).fold(Monoid[R].empty)(c => indexed.runIndex.runForget((c, i))) }) } - /** compose this [[IndexedFold_]] with an [[ATraversal_]], having this [[IndexedFold_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedFold_]] with an [[ATraversal_]], having this [[IndexedFold_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((a, i)) })) } - /** compose this [[IndexedFold_]] with a [[Getter_]], having this [[IndexedFold_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedFold_]] with a [[Getter_]], having this [[IndexedFold_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((other.view(a), i)) }) } - /** compose this [[IndexedFold_]] with a [[Getter_]], having this [[IndexedFold_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedFold_]] with a [[Getter_]], having this [[IndexedFold_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c)) { case (a, i) => indexed.runIndex.runForget((a, i)) }) } - /** compose this [[IndexedFold_]] with a function lifted to a [[Getter_]], having this [[IndexedFold_]] applied last */ - final def to[C, D](f: A => C): IndexedFold_[I, S, T, C, D] = compose(Getter_[A, B, C, D](f)) + /** compose this [[IndexedFold_]] with a function lifted to a [[Getter_]], having this [[IndexedFold_]] applied first */ + final def to[C, D](f: A => C): IndexedFold_[I, S, T, C, D] = andThen(Getter_[A, B, C, D](f)) - /** compose this [[IndexedFold_]] with a [[Fold_]], having this [[IndexedFold_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedFold_]] with a [[Fold_]], having this [[IndexedFold_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => other.foldMap(a)(c => indexed.runIndex.runForget((c, i))) }) } - /** compose this [[IndexedFold_]] with a [[Fold_]], having this [[IndexedFold_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedFold_]] with a [[Fold_]], having this [[IndexedFold_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((a, i)) })) } /** compose this [[IndexedFold_]] with an [[IndexedLens_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], J, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(indexed.runIndex.runForget compose other.view compose Tuple2._1)) } /** compose [[IndexedFold_]] with an [[IndexedLens_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedFold_]] with an [[IndexedLens_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((other.view(a)._1, i)) }) } /** compose this [[IndexedFold_]] with an [[IndexedLens_]], while preserving self indices */ - final def <<*[C, D](other: IndexedLens_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedLens_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedFold_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], J, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(indexed.runIndex.runForget compose other.view compose Tuple2._1)) } /** compose [[IndexedFold_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedFold_]] with an [[AnIndexedLens_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: AnIndexedLens_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: AnIndexedLens_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((other.view(a)._1, i)) }) } /** compose this [[IndexedFold_]] with an [[AnIndexedLens_]], while preserving self indices */ - final def <<*[C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedFold_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], J, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, _) => other.foldMap(a)(indexed.runIndex.runForget) }) } /** compose [[IndexedFold_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedFold_]] with an [[IndexedTraversal_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => other.foldMap(a) { case (c, _) => indexed.runIndex.runForget((c, i)) } }) } /** compose this [[IndexedFold_]] with an [[IndexedTraversal_]], while preserving self indices */ - final def <<*[C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedFold_]] with an [[IndexedGetter_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], J, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, _) => indexed.runIndex.runForget(other.view(a)) }) } /** compose [[IndexedFold_]] with an [[IndexedGetter_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedFold_]] with an [[IndexedGetter_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((other.view(a)._1, i)) }) } /** compose this [[IndexedFold_]] with an [[IndexedGetter_]], while preserving self indices */ - final def <<*[C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedFold_]] with an [[IndexedFold_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], J, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, _) => other.foldMap(a)(indexed.runIndex.runForget) }) } /** compose [[IndexedFold_]] with an [[IndexedFold_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedFold_]] with an [[IndexedFold_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => other.foldMap(a) { case (c, _) => indexed.runIndex.runForget((c, i)) } }) } /** compose this [[IndexedFold_]] with an [[IndexedFold_]], while preserving self indices */ - final def <<*[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedFold_]] with a function lifted to an [[IndexedGetter_]] */ - final def toWithIndex[C, D](f: A => (C, I)): IndexedFold_[I, S, T, C, D] = composeWithLeftIndex(IndexedGetter_[I, A, B, C, D](f)) + final def toWithIndex[C, D](f: A => (C, I)): IndexedFold_[I, S, T, C, D] = andThenWithLeftIndex(IndexedGetter_[I, A, B, C, D](f)) private def minMax(s: S)(f: (A, A) => A): Option[A] = foldRight[Option[A]](s)(None)((pair, op) => f(pair._1, op.getOrElse(pair._1)).some) diff --git a/core/shared/src/main/scala/proptics/IndexedGetter.scala b/core/shared/src/main/scala/proptics/IndexedGetter.scala index 61ab566e9..06874978a 100644 --- a/core/shared/src/main/scala/proptics/IndexedGetter.scala +++ b/core/shared/src/main/scala/proptics/IndexedGetter.scala @@ -66,8 +66,8 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => Forget(indexed.runIndex.runForget compose self.view) } - /** compose this [[IndexedGetter_]] with an [[Iso_]], having this [[IndexedGetter_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedGetter_]] with an [[Iso_]], having this [[IndexedGetter_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -75,14 +75,14 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with an [[Iso_]], having this [[IndexedGetter_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedGetter_]] with an [[Iso_]], having this [[IndexedGetter_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(indexed.runIndex.runForget compose self.view compose other.view) } - /** compose this [[IndexedGetter_]] with an [[AnIso_]], having this [[IndexedGetter_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedGetter_]] with an [[AnIso_]], having this [[IndexedGetter_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -90,14 +90,14 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with an [[AnIso_]], having this [[IndexedGetter_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedGetter_]] with an [[AnIso_]], having this [[IndexedGetter_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(indexed.runIndex.runForget compose self.view compose other.view) } - /** compose this [[IndexedGetter_]] with a [[Lens_]], having this [[IndexedGetter_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedGetter_]] with a [[Lens_]], having this [[IndexedGetter_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -105,14 +105,14 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with a [[Lens_]], having this [[IndexedGetter_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedGetter_]] with a [[Lens_]], having this [[IndexedGetter_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(indexed.runIndex.runForget compose self.view compose other.view) } - /** compose this [[IndexedGetter_]] with an [[ALens_]], having this [[IndexedGetter_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedGetter_]] with an [[ALens_]], having this [[IndexedGetter_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -120,14 +120,14 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with a [[ALens_]], having this [[IndexedGetter_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedGetter_]] with a [[ALens_]], having this [[IndexedGetter_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(indexed.runIndex.runForget compose self.view compose other.view) } - /** compose this [[IndexedGetter_]] with a [[Prism_]], having this [[IndexedGetter_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedGetter_]] with a [[Prism_]], having this [[IndexedGetter_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -135,8 +135,8 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with a [[Prism_]], having this [[IndexedGetter_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedGetter_]] with a [[Prism_]], having this [[IndexedGetter_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => other @@ -145,8 +145,8 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with an [[APrism_]], having this [[IndexedGetter_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedGetter_]] with an [[APrism_]], having this [[IndexedGetter_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -154,8 +154,8 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with an [[APrism_]], having this [[IndexedGetter_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedGetter_]] with an [[APrism_]], having this [[IndexedGetter_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => other @@ -164,8 +164,8 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with an [[AffineTraversal_]], having this [[IndexedGetter_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedGetter_]] with an [[AffineTraversal_]], having this [[IndexedGetter_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -173,8 +173,8 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with an [[AffineTraversal_]], having this [[IndexedGetter_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedGetter_]] with an [[AffineTraversal_]], having this [[IndexedGetter_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => other @@ -183,8 +183,8 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with an [[AnAffineTraversal_]], having this [[IndexedGetter_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedGetter_]] with an [[AnAffineTraversal_]], having this [[IndexedGetter_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -192,8 +192,8 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with an [[AnAffineTraversal_]], having this [[IndexedGetter_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedGetter_]] with an [[AnAffineTraversal_]], having this [[IndexedGetter_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => other @@ -202,8 +202,8 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with a [[Traversal_]], having this [[IndexedGetter_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedGetter_]] with a [[Traversal_]], having this [[IndexedGetter_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -211,14 +211,14 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with a [[Traversal_]], having this [[IndexedGetter_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedGetter_]] with a [[Traversal_]], having this [[IndexedGetter_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(indexed.runIndex.runForget compose self.view)) } - /** compose this [[IndexedGetter_]] with an [[ATraversal_]], having this [[IndexedGetter_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedGetter_]] with an [[ATraversal_]], having this [[IndexedGetter_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -226,14 +226,14 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with an [[ATraversal_]], having this [[IndexedGetter_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedGetter_]] with an [[ATraversal_]], having this [[IndexedGetter_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(indexed.runIndex.runForget compose self.view)) } - /** compose this [[IndexedGetter_]] with a [[Getter_]], having this [[IndexedGetter_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedGetter_]] with a [[Getter_]], having this [[IndexedGetter_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -241,8 +241,8 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with a [[Getter_]], having this [[IndexedGetter_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedGetter_]] with a [[Getter_]], having this [[IndexedGetter_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => val (a, i) = self.view(other.view(c)) @@ -250,8 +250,8 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with a [[Fold_]], having this [[IndexedGetter_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedGetter_]] with a [[Fold_]], having this [[IndexedGetter_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -259,8 +259,8 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } } - /** compose this [[IndexedGetter_]] with a [[Fold_]], having this [[IndexedGetter_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedGetter_]] with a [[Fold_]], having this [[IndexedGetter_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { other.foldMap(_) { s => @@ -271,52 +271,52 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } /** compose an [[IndexedGetter_]] with an [[IndexedLens_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = new IndexedGetter_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = new IndexedGetter_[J, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[Forget[(C, J), *, *], J, C, D]): Forget[(C, J), S, T] = Forget(other.view _ compose Tuple2._1[A, I] compose self.view) } /** compose [[IndexedGetter_]] with an [[IndexedLens_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[IndexedGetter_]] with an [[IndexedLens_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[Forget[(C, I), *, *], I, C, D]): Forget[(C, I), S, T] = Forget(self.view(_).leftMap(other.view(_)._1)) } /** compose [[IndexedGetter_]] with an [[IndexedLens_]], while preserving self indices */ - final def <<*[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose an [[IndexedGetter_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = new IndexedGetter_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = new IndexedGetter_[J, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[Forget[(C, J), *, *], J, C, D]): Forget[(C, J), S, T] = Forget(other.view _ compose Tuple2._1[A, I] compose self.view) } /** compose [[IndexedGetter_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[IndexedGetter_]] with an [[AnIndexedLens_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: AnIndexedLens_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: AnIndexedLens_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[Forget[(C, I), *, *], I, C, D]): Forget[(C, I), S, T] = Forget(self.view(_).leftMap(other.view(_)._1)) } /** compose [[IndexedGetter_]] with an [[AnIndexedLens_]], while preserving self indices */ - final def <<*[C, D](other: AnIndexedLens_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: AnIndexedLens_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose an [[IndexedGetter_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], J, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s)._1)(indexed.runIndex.runForget)) } /** compose [[IndexedGetter_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[IndexedGetter_]] with an [[IndexedTraversal_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -325,19 +325,19 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } /** compose [[IndexedGetter_]] with an [[IndexedTraversal_]], while preserving self indices */ - final def <<*[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose [[IndexedGetter_]] with an [[IndexedGetter_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = new IndexedGetter_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = new IndexedGetter_[J, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[Forget[(C, J), *, *], J, C, D]): Forget[(C, J), S, T] = Forget(other.view _ compose Tuple2._1[A, I] compose self.view) } /** compose [[IndexedGetter_]] with an [[IndexedGetter_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose [[IndexedGetter_]] with an [[IndexedGetter_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[Forget[(C, I), *, *], I, C, D]): Forget[(C, I), S, T] = Forget { s => val (a, i) = self.view(s) @@ -348,19 +348,19 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } /** compose [[IndexedGetter_]] with an [[IndexedGetter_]], while preserving self indices */ - final def <<*[C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose [[IndexedGetter_]] with an [[IndexedFold_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], J, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s)._1)(indexed.runIndex.runForget)) } /** compose [[IndexedGetter_]] with an [[IndexedFold_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose [[IndexedGetter_]] with an [[IndexedFold_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -369,7 +369,7 @@ abstract class IndexedGetter_[I, S, T, A, B] extends Serializable { self => } /** compose [[IndexedGetter_]] with an [[IndexedFold_]], while preserving self indices */ - final def <<*[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = andThenWithLeftIndex(other) private def toForget: Forget[(A, I), S, T] = self(Indexed(Forget(identity))) } diff --git a/core/shared/src/main/scala/proptics/IndexedLens.scala b/core/shared/src/main/scala/proptics/IndexedLens.scala index 6920e8dd3..43f6b99d2 100644 --- a/core/shared/src/main/scala/proptics/IndexedLens.scala +++ b/core/shared/src/main/scala/proptics/IndexedLens.scala @@ -109,136 +109,136 @@ abstract class IndexedLens_[I, S, T, A, B] extends Serializable { self => Forget(indexed.runIndex.runForget compose self.view) } - /** compose this [[IndexedLens_]] with an [[Iso_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): IndexedLens_[I, S, T, C, D] = + /** compose this [[IndexedLens_]] with an [[Iso_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): IndexedLens_[I, S, T, C, D] = IndexedLens_((s: S) => self.view(s).leftMap(other.view))(s => d => self.set(other.set(d)(self.view(s)._1))(s)) - /** compose this [[IndexedLens_]] with an [[Iso_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): IndexedLens_[I, C, D, A, B] = + /** compose this [[IndexedLens_]] with an [[Iso_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): IndexedLens_[I, C, D, A, B] = IndexedLens_((c: C) => self.view(other.view(c)))(c => b => other.set(self.set(b)(other.view(c)))(c)) - /** compose this [[IndexedLens_]] with an [[AnIso_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): IndexedLens_[I, S, T, C, D] = + /** compose this [[IndexedLens_]] with an [[AnIso_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): IndexedLens_[I, S, T, C, D] = IndexedLens_((s: S) => self.view(s).leftMap(other.view))(s => d => self.set(other.set(d)(self.view(s)._1))(s)) - /** compose this [[IndexedLens_]] with an [[AnIso_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): IndexedLens_[I, C, D, A, B] = + /** compose this [[IndexedLens_]] with an [[AnIso_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): IndexedLens_[I, C, D, A, B] = IndexedLens_((c: C) => self.view(other.view(c)))(c => b => other.set(self.set(b)(other.view(c)))(c)) - /** compose this [[IndexedLens_]] with a [[Lens_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): IndexedLens_[I, S, T, C, D] = + /** compose this [[IndexedLens_]] with a [[Lens_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): IndexedLens_[I, S, T, C, D] = IndexedLens_[I, S, T, C, D]((s: S) => self.view(s).leftMap(other.view))(s => d => self.set(other.set(d)(self.view(s)._1))(s)) - /** compose this [[IndexedLens_]] with a [[Lens_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): IndexedLens_[I, C, D, A, B] = + /** compose this [[IndexedLens_]] with a [[Lens_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): IndexedLens_[I, C, D, A, B] = IndexedLens_((c: C) => self.view(other.view(c)))(c => b => other.set(self.set(b)(other.view(c)))(c)) - /** compose this [[IndexedLens_]] with an [[ALens_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): IndexedLens_[I, S, T, C, D] = + /** compose this [[IndexedLens_]] with an [[ALens_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): IndexedLens_[I, S, T, C, D] = IndexedLens_((s: S) => self.view(s).leftMap(other.view))(s => d => self.set(other.set(d)(self.view(s)._1))(s)) - /** compose this [[IndexedLens_]] with an [[ALens_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): IndexedLens_[I, C, D, A, B] = + /** compose this [[IndexedLens_]] with an [[ALens_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): IndexedLens_[I, C, D, A, B] = IndexedLens_((c: C) => self.view(other.view(c)))(c => b => other.set(self.set(b)(other.view(c)))(c)) - /** compose this [[IndexedLens_]] with a [[Prism_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedLens_]] with a [[Prism_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedLens_]] with a [[Prism_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedLens_]] with a [[Prism_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedLens_]] with an [[APrism_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedLens_]] with an [[APrism_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedLens_]] with an [[APrism_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedLens_]] with an [[APrism_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedLens_]] with an [[AffineTraversal_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedLens_]] with an [[AffineTraversal_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedLens_]] with an [[AffineTraversal_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedLens_]] with an [[AffineTraversal_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedLens_]] with an [[AnAffineTraversal_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedLens_]] with an [[AnAffineTraversal_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedLens_]] with an [[AnAffineTraversal_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedLens_]] with an [[AnAffineTraversal_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedLens_]] with a [[Traversal_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedLens_]] with a [[Traversal_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedLens_]] with a [[Traversal_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedLens_]] with a [[Traversal_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedLens_]] with an [[ATraversal_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedLens_]] with an [[ATraversal_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedLens_]] with an [[ATraversal_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedLens_]] with an [[ATraversal_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose an [[IndexedTraversal_]] with a [[Setter_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose an [[IndexedTraversal_]] with a [[Setter_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) } } - /** compose an [[IndexedTraversal_]] with a [[Setter_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose an [[IndexedTraversal_]] with a [[Setter_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(self.over { case (a, i) => indexed.runIndex((a, i)) }) } - /** compose an [[IndexedTraversal_]] with a [[Getter_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { + /** compose an [[IndexedTraversal_]] with a [[Getter_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[Forget[(C, I), *, *], I, C, D]): Forget[(C, I), S, T] = Forget { s => val (a, i) = self.view(s) @@ -246,14 +246,14 @@ abstract class IndexedLens_[I, S, T, A, B] extends Serializable { self => } } - /** compose an [[IndexedTraversal_]] with a [[Getter_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): IndexedGetter_[I, C, D, A, B] = new IndexedGetter_[I, C, D, A, B] { + /** compose an [[IndexedTraversal_]] with a [[Getter_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): IndexedGetter_[I, C, D, A, B] = new IndexedGetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[Forget[(A, I), *, *], I, A, B]): Forget[(A, I), C, D] = Forget(indexed.runIndex.runForget compose self.view compose other.view) } - /** compose an [[IndexedTraversal_]] with a [[Fold_]], having this [[IndexedLens_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose an [[IndexedTraversal_]] with a [[Fold_]], having this [[IndexedLens_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget { s => val (a, i) = self.view(s) @@ -261,8 +261,8 @@ abstract class IndexedLens_[I, S, T, A, B] extends Serializable { self => } } - /** compose an [[IndexedTraversal_]] with a [[Fold_]], having this [[IndexedLens_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose an [[IndexedTraversal_]] with a [[Fold_]], having this [[IndexedLens_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => other.foldMap(c) { s => @@ -273,114 +273,114 @@ abstract class IndexedLens_[I, S, T, A, B] extends Serializable { self => } /** compose this [[IndexedLens_]] with an [[IndexedLens_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedLens_[J, S, T, C, D] = new IndexedLens_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedLens_[J, S, T, C, D] = new IndexedLens_[J, S, T, C, D] { override private[proptics] def apply[P[_, _]](indexed: Indexed[P, J, C, D])(implicit ev: Strong[P]): P[S, T] = self(Indexed(ev.lmap[A, B, (A, I)](other(indexed))(_._1))) } /** compose this [[IndexedLens_]] with an [[IndexedLens_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedLens_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedLens_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedLens_]] with an [[IndexedLens_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedLens_[I, S, T, C, D] = + final def andThenWithLeftIndex[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedLens_[I, S, T, C, D] = IndexedLens_[I, S, T, C, D]((s: S) => self.view(s).leftMap(other.view(_)._1)) { s => d => self.set(other.set(d)(self.view(s)._1))(s) } /** compose this [[IndexedLens_]] with an [[IndexedLens_]], while preserving self indices */ - final def <<*[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedLens_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedLens_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedLens_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): AnIndexedLens_[J, S, T, C, D] = new AnIndexedLens_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): AnIndexedLens_[J, S, T, C, D] = new AnIndexedLens_[J, S, T, C, D] { override def apply(indexed: Indexed[Shop[(C, J), D, *, *], J, C, D]): Shop[(C, J), D, S, T] = Shop[(C, J), D, S, T](s => other.view(self.view(s)._1), s => d => self.set(other.set(d)(self.view(s)._1))(s)) } /** compose this [[IndexedLens_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): AnIndexedLens_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): AnIndexedLens_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedLens_]] with an [[AnIndexedLens_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: AnIndexedLens_[_, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = new AnIndexedLens_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: AnIndexedLens_[_, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = new AnIndexedLens_[I, S, T, C, D] { override def apply(indexed: Indexed[Shop[(C, I), D, *, *], I, C, D]): Shop[(C, I), D, S, T] = Shop[(C, I), D, S, T](s => self.view(s).leftMap(other.view(_)._1), s => d => self.set(other.set(d)(self.view(s)._1))(s)) } /** compose this [[IndexedLens_]] with an [[AnIndexedLens_]], while preserving self indices */ - final def <<*[C, D](other: AnIndexedLens_[_, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: AnIndexedLens_[_, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedLens_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = + final def andThenWithRightIndex[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[J, S, T, C, D] { override def apply[F[_]](f: ((C, J)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, _) => other.overF(f)(a) } }) /** compose this [[IndexedLens_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedLens_]] with an [[IndexedTraversal_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + final def andThenWithLeftIndex[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.overF { case (c, _) => f((c, i)) }(a) } }) /** compose this [[IndexedLens_]] with an [[IndexedTraversal_]], while preserving self indices */ - final def <<*[J, C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[J, C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedLens_]] with an [[IndexedSetter_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, J, C, D]): S => T = self(Indexed[* => *, I, A, B](other(indexed) compose Tuple2._1)) } /** compose this [[IndexedLens_]] with an [[IndexedSetter_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedLens_]] with an [[IndexedSetter_]], while preserving self indices */ - final def composeWithLeftIndex[J, C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + final def andThenWithLeftIndex[J, C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self(Indexed[* => *, I, A, B] { case (a, i) => other.over { case (c, _) => indexed.runIndex((c, i)) }(a) }) } /** compose this [[IndexedLens_]] with an [[IndexedSetter_]], while preserving self indices */ - final def <<*[J, C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[J, C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedLens_]] with an [[IndexedGetter_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = new IndexedGetter_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = new IndexedGetter_[J, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[Forget[(C, J), *, *], J, C, D]): Forget[(C, J), S, T] = Forget(other.view _ compose Tuple2._1[A, I] compose self.view) } /** compose this [[IndexedLens_]] with an [[IndexedGetter_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedGetter_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedLens_]] with an [[IndexedGetter_]], while preserving self indices */ - final def composeWithLeftIndex[J, C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { + final def andThenWithLeftIndex[J, C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = new IndexedGetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[Forget[(C, I), *, *], I, C, D]): Forget[(C, I), S, T] = Forget(s => self.view(s).leftMap(other.view(_)._1)) } /** compose this [[IndexedLens_]] with an [[IndexedGetter_]], while preserving self indices */ - final def <<*[J, C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[J, C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedGetter_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedLens_]] with an [[IndexedFold_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], J, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s)._1)(indexed.runIndex.runForget)) } /** compose this [[IndexedLens_]] with an [[IndexedFold_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedLens_]] with an [[IndexedFold_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s)._1) { case (c, _) => indexed.runIndex.runForget((c, self.view(s)._2)) }) } /** compose this [[IndexedLens_]] with an [[IndexedFold_]], while preserving self indices */ - final def <<*[J, C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[J, C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = andThenWithLeftIndex(other) } object IndexedLens_ { diff --git a/core/shared/src/main/scala/proptics/IndexedSetter.scala b/core/shared/src/main/scala/proptics/IndexedSetter.scala index 488f72739..381211928 100644 --- a/core/shared/src/main/scala/proptics/IndexedSetter.scala +++ b/core/shared/src/main/scala/proptics/IndexedSetter.scala @@ -35,208 +35,208 @@ abstract class IndexedSetter_[I, S, T, A, B] extends Serializable { self => self(Indexed(pab compose Tuple2._1[A, I])) } - /** compose this [[IndexedSetter_]] with an [[Iso_]], having this [[IndexedSetter_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[IndexedSetter_]] with an [[Iso_]], having this [[IndexedSetter_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) } } - /** compose this [[IndexedSetter_]] with an [[Iso_]], having this [[IndexedSetter_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[IndexedSetter_]] with an [[Iso_]], having this [[IndexedSetter_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(self.over { case (a, i) => indexed.runIndex((a, i)) }) } - /** compose this [[IndexedSetter_]] with an [[AnIso_]], having this [[IndexedSetter_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[IndexedSetter_]] with an [[AnIso_]], having this [[IndexedSetter_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) } } - /** compose this [[IndexedSetter_]] with an [[AnIso_]], having this [[IndexedSetter_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[IndexedSetter_]] with an [[AnIso_]], having this [[IndexedSetter_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(self.over { case (a, i) => indexed.runIndex((a, i)) }) } - /** compose this [[IndexedSetter_]] with a [[Lens_]], having this [[IndexedSetter_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[IndexedSetter_]] with a [[Lens_]], having this [[IndexedSetter_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) } } - /** compose this [[IndexedSetter_]] with a [[Lens_]], having this [[IndexedSetter_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[IndexedSetter_]] with a [[Lens_]], having this [[IndexedSetter_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(self.over { case (a, i) => indexed.runIndex((a, i)) }) } - /** compose this [[IndexedSetter_]] with an [[ALens_]], having this [[IndexedSetter_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[IndexedSetter_]] with an [[ALens_]], having this [[IndexedSetter_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) } } - /** compose this [[IndexedSetter_]] with an [[ALens_]], having this [[IndexedSetter_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[IndexedSetter_]] with an [[ALens_]], having this [[IndexedSetter_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(self.over { case (a, i) => indexed.runIndex((a, i)) }) } - /** compose this [[IndexedSetter_]] with a [[Prism_]], having this [[IndexedSetter_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[IndexedSetter_]] with a [[Prism_]], having this [[IndexedSetter_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) } } - /** compose this [[IndexedSetter_]] with a [[Prism_]], having this [[IndexedSetter_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[IndexedSetter_]] with a [[Prism_]], having this [[IndexedSetter_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(self.over { case (a, i) => indexed.runIndex((a, i)) }) } - /** compose this [[IndexedSetter_]] with an [[AffineTraversal_]], having this [[IndexedSetter_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[IndexedSetter_]] with an [[AffineTraversal_]], having this [[IndexedSetter_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) } } - /** compose this [[IndexedSetter_]] with an [[AffineTraversal_]], having this [[IndexedSetter_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[IndexedSetter_]] with an [[AffineTraversal_]], having this [[IndexedSetter_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(self.over { case (a, i) => indexed.runIndex((a, i)) }) } - /** compose this [[IndexedSetter_]] with an [[AnAffineTraversal_]], having this [[IndexedSetter_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[IndexedSetter_]] with an [[AnAffineTraversal_]], having this [[IndexedSetter_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) } } - /** compose this [[IndexedSetter_]] with an [[AnAffineTraversal_]], having this [[IndexedSetter_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[IndexedSetter_]] with an [[AnAffineTraversal_]], having this [[IndexedSetter_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(self.over { case (a, i) => indexed.runIndex((a, i)) }) } - /** compose this [[IndexedSetter_]] with a [[Traversal_]], having this [[IndexedSetter_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[IndexedSetter_]] with a [[Traversal_]], having this [[IndexedSetter_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) } } - /** compose this [[IndexedSetter_]] with a [[Traversal_]], having this [[IndexedSetter_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[IndexedSetter_]] with a [[Traversal_]], having this [[IndexedSetter_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(self.over { case (a, i) => indexed.runIndex((a, i)) }) } - /** compose this [[IndexedSetter_]] with an [[ATraversal_]], having this [[IndexedSetter_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[IndexedSetter_]] with an [[ATraversal_]], having this [[IndexedSetter_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) } } - /** compose this [[IndexedSetter_]] with an [[ATraversal_]], having this [[IndexedSetter_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[IndexedSetter_]] with an [[ATraversal_]], having this [[IndexedSetter_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(self.over { case (a, i) => indexed.runIndex((a, i)) }) } - /** compose this [[IndexedSetter_]] with a [[Setter_]], having this [[IndexedSetter_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[IndexedSetter_]] with a [[Setter_]], having this [[IndexedSetter_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) } } - /** compose this [[IndexedSetter_]] with a [[Setter_]], having this [[IndexedSetter_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[IndexedSetter_]] with a [[Setter_]], having this [[IndexedSetter_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(self.over { case (a, i) => indexed.runIndex((a, i)) }) } - /** compose this [[IndexedSetter_]] with a [[Grate_]], having this [[IndexedSetter_]] applied last */ - final def compose[C, D](other: Grate_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[IndexedSetter_]] with a [[Grate_]], having this [[IndexedSetter_]] applied first */ + final def andThen[C, D](other: Grate_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) } } - /** compose this [[IndexedSetter_]] with a [[Grate_]], having this [[IndexedSetter_]] applied first */ - final def andThen[C, D](other: Grate_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[IndexedSetter_]] with a [[Grate_]], having this [[IndexedSetter_]] applied last */ + final def compose[C, D](other: Grate_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(self.over { case (a, i) => indexed.runIndex((a, i)) }) } /** compose an [[IndexedSetter_]] with an [[IndexedLens_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, J, C, D]): S => T = self(Indexed(other(indexed) compose Tuple2._1[A, I])) } /** compose an [[IndexedLens_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[IndexedSetter_]] with an [[IndexedLens_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over { case (c, _) => indexed.runIndex((c, i)) }(a) } } /** compose an [[IndexedLens_]] with an [[IndexedLens_]], while preserving self indices */ - final def <<*[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose an [[IndexedSetter_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, J, C, D]): S => T = self.over { case (a, _) => other.over { case (c, j) => indexed.runIndex((c, j)) }(a) } } /** compose an [[IndexedSetter_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def *>>[C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = composeWithRightIndex(other) + final def *>>[C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[IndexedSetter_]] with an [[AnIndexedLens_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: AnIndexedLens_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: AnIndexedLens_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over { case (c, _) => indexed.runIndex((c, i)) }(a) } } /** compose an [[IndexedLens_]] with an [[AnIndexedLens_]], while preserving self indices */ - final def <<*[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose an [[IndexedLens_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, J, C, D]): S => T = self(Indexed(other(indexed) compose Tuple2._1[A, I])) } /** compose an [[IndexedSetter_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def *>>[C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = composeWithRightIndex(other) + final def *>>[C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[IndexedSetter_]] with an [[IndexedTraversal_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over { case (c, _) => indexed.runIndex((c, i)) }(a) } } /** compose an [[IndexedLens_]] with an [[IndexedTraversal_]], while preserving self indices */ - final def <<*[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = andThenWithLeftIndex(other) - final def composeWithRightIndex[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, J, C, D]): S => T = self(Indexed(other(indexed) compose Tuple2._1[A, I])) } /** compose an [[IndexedSetter_]] with an [[IndexedSetter_]], while preserving the indices of the other optic */ - final def *>>[C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = composeWithRightIndex(other) + final def *>>[C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = andThenWithRightIndex(other) /** compose an [[IndexedSetter_]] with an [[IndexedSetter_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over { case (a, i) => other.over { case (c, _) => indexed.runIndex((c, i)) }(a) } } /** compose an [[IndexedLens_]] with an [[IndexedSetter_]], while preserving self indices */ - final def <<*[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = andThenWithLeftIndex(other) } diff --git a/core/shared/src/main/scala/proptics/IndexedTraversal.scala b/core/shared/src/main/scala/proptics/IndexedTraversal.scala index c79948c99..c2bc96da8 100644 --- a/core/shared/src/main/scala/proptics/IndexedTraversal.scala +++ b/core/shared/src/main/scala/proptics/IndexedTraversal.scala @@ -161,184 +161,184 @@ abstract class IndexedTraversal_[I, S, T, A, B] extends Serializable { self => Forget(self.foldMap(_)(indexed.runIndex.runForget)) } - /** compose this [[IndexedTraversal_]] with an [[Iso_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedTraversal_]] with an [[Iso_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedTraversal_]] with an [[Iso_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedTraversal_]] with an [[Iso_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedTraversal_]] with an [[AnIso_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedTraversal_]] with an [[AnIso_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedTraversal_]] with an [[AnIso_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedTraversal_]] with an [[AnIso_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedTraversal_]] with a [[Lens_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedTraversal_]] with a [[Lens_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedTraversal_]] with a [[Lens_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedTraversal_]] with a [[Lens_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedTraversal_]] with an [[ALens_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedTraversal_]] with an [[ALens_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedTraversal_]] with an [[ALens_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedTraversal_]] with an [[ALens_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedTraversal_]] with a [[Prism_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedTraversal_]] with a [[Prism_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedTraversal_]] with a [[Prism_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedTraversal_]] with a [[Prism_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedTraversal_]] with an [[APrism_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedTraversal_]] with an [[APrism_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedTraversal_]] with an [[APrism_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedTraversal_]] with an [[APrism_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedTraversal_]] with an [[AffineTraversal_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedTraversal_]] with an [[AffineTraversal_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedTraversal_]] with an [[AffineTraversal_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedTraversal_]] with an [[AffineTraversal_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedTraversal_]] with an [[AnAffineTraversal_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedTraversal_]] with an [[AnAffineTraversal_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedTraversal_]] with an [[AnAffineTraversal_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedTraversal_]] with an [[AnAffineTraversal_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedTraversal_]] with a [[Traversal_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedTraversal_]] with a [[Traversal_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedTraversal_]] with a [[Traversal_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedTraversal_]] with a [[Traversal_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedTraversal_]] with an [[ATraversal_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[IndexedTraversal_]] with an [[ATraversal_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF { case (a, i) => other.traverse(a)(c => f((c, i))) } }) - /** compose this [[IndexedTraversal_]] with an [[ATraversal_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[IndexedTraversal_]] with an [[ATraversal_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF { case (a, i) => f((a, i)) }) }) - /** compose this [[IndexedTraversal_]] with a [[Setter_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[IndexedTraversal_]] with a [[Setter_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self(Indexed[* => *, I, A, B] { case (a, i) => other.over(c => indexed.runIndex((c, i)))(a) }) } - /** compose this [[IndexedTraversal_]] with a [[Setter_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[IndexedTraversal_]] with a [[Setter_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over(s => self.over { case (a, i) => indexed.runIndex((a, i)) }(s)) } - /** compose this [[IndexedTraversal_]] with a [[Getter_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedTraversal_]] with a [[Getter_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((other.view(a), i)) }) } - /** compose this [[IndexedTraversal_]] with a [[Getter_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedTraversal_]] with a [[Getter_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c)) { case (a, i) => indexed.runIndex.runForget((a, i)) }) } - /** compose this [[IndexedTraversal_]] with a [[Fold_]], having this [[IndexedTraversal_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[IndexedTraversal_]] with a [[Fold_]], having this [[IndexedTraversal_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => other.foldMap(a)(c => indexed.runIndex.runForget((c, i))) }) } - /** compose this [[IndexedTraversal_]] with a [[Fold_]], having this [[IndexedTraversal_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[IndexedTraversal_]] with a [[Fold_]], having this [[IndexedTraversal_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(self.foldMap(_) { case (a, i) => indexed.runIndex.runForget((a, i)) })) } /** compose this [[IndexedTraversal_]] with an [[IndexedLens_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = new IndexedTraversal_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = new IndexedTraversal_[J, S, T, C, D] { override def apply[P[_, _]](indexed: Indexed[P, J, C, D])(implicit ev: Wander[P]): P[S, T] = { val traversing: Traversing[S, T, (C, J), D] = new Traversing[S, T, (C, J), D] { override def apply[F[_]](f: ((C, J)) => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = @@ -350,10 +350,10 @@ abstract class IndexedTraversal_[I, S, T, A, B] extends Serializable { self => } /** compose this [[IndexedTraversal_]] with an [[IndexedLens_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedLens_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedTraversal_]] with an [[IndexedLens_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = new IndexedTraversal_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = new IndexedTraversal_[I, S, T, C, D] { override def apply[P[_, _]](indexed: Indexed[P, I, C, D])(implicit ev: Wander[P]): P[S, T] = { val traversing: Traversing[S, T, (C, I), D] = new Traversing[S, T, (C, I), D] { override def apply[F[_]](f: ((C, I)) => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = @@ -365,22 +365,22 @@ abstract class IndexedTraversal_[I, S, T, A, B] extends Serializable { self => } /** compose this [[IndexedTraversal_]] with an [[IndexedLens_]], while preserving self indices */ - final def <<*[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedLens_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedTraversal_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = composeWithRightIndex(other.asIndexedLens) + final def andThenWithRightIndex[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = andThenWithRightIndex(other.asIndexedLens) /** compose this [[IndexedTraversal_]] with an [[AnIndexedLens_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: AnIndexedLens_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedTraversal_]] with an [[AnIndexedLens_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: AnIndexedLens_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = composeWithLeftIndex(other.asIndexedLens) + final def andThenWithLeftIndex[C, D](other: AnIndexedLens_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = andThenWithLeftIndex(other.asIndexedLens) /** compose this [[IndexedTraversal_]] with an [[AnIndexedLens_]], while preserving self indices */ - final def <<*[C, D](other: AnIndexedLens_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: AnIndexedLens_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedTraversal_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = new IndexedTraversal_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = new IndexedTraversal_[J, S, T, C, D] { override def apply[P[_, _]](indexed: Indexed[P, J, C, D])(implicit ev: Wander[P]): P[S, T] = { val traversing: Traversing[S, T, (C, J), D] = new Traversing[S, T, (C, J), D] { override def apply[F[_]](f: ((C, J)) => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = @@ -392,10 +392,10 @@ abstract class IndexedTraversal_[I, S, T, A, B] extends Serializable { self => } /** compose this [[IndexedTraversal_]] with an [[IndexedTraversal_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedTraversal_[J, A, B, C, D]): IndexedTraversal_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedTraversal_]] with an [[IndexedTraversal_]], while preserving self indices */ - final def composeWithLeftIndex[_, C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = new IndexedTraversal_[I, S, T, C, D] { + final def andThenWithLeftIndex[_, C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = new IndexedTraversal_[I, S, T, C, D] { override def apply[P[_, _]](indexed: Indexed[P, I, C, D])(implicit ev: Wander[P]): P[S, T] = { val traversing: Traversing[S, T, (C, I), D] = new Traversing[S, T, (C, I), D] { override def apply[F[_]](f: ((C, I)) => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = @@ -407,19 +407,19 @@ abstract class IndexedTraversal_[I, S, T, A, B] extends Serializable { self => } /** compose this [[IndexedTraversal_]] with an [[IndexedTraversal_]], while preserving self indices */ - final def <<*[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedTraversal_[_, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedTraversal_]] with an [[IndexedSetter_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = new IndexedSetter_[J, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, J, C, D]): S => T = self(Indexed[* => *, I, A, B](other(indexed) compose Tuple2._1)) } /** compose this [[IndexedTraversal_]] with an [[IndexedSetter_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedSetter_[J, A, B, C, D]): IndexedSetter_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedTraversal_]] with an [[IndexedSetter_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self(Indexed[* => *, I, A, B] { case (a, i) => other.over { case (c, _) => indexed.runIndex((c, i)) }(a) @@ -427,24 +427,24 @@ abstract class IndexedTraversal_[I, S, T, A, B] extends Serializable { self => } /** compose this [[IndexedTraversal_]] with an [[IndexedSetter_]], while preserving self indices */ - final def <<*[C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedSetter_[_, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose this [[IndexedTraversal_]] with an [[IndexedGetter_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = - composeWithRightIndex(other.asIndexedFold) + final def andThenWithRightIndex[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = + andThenWithRightIndex(other.asIndexedFold) /** compose this [[IndexedTraversal_]] with an [[IndexedGetter_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedGetter_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose this [[IndexedTraversal_]] with an [[IndexedGetter_]], while preserving self indices */ - final def composeWithLeftIndex[J, C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = - composeWithLeftIndex(other.asIndexedFold) + final def andThenWithLeftIndex[J, C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = + andThenWithLeftIndex(other.asIndexedFold) /** compose this [[IndexedTraversal_]] with an [[IndexedGetter_]], while preserving self indices */ - final def <<*[C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedGetter_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = andThenWithLeftIndex(other) /** compose [[IndexedTraversal_]] with an [[IndexedFold_]], while preserving the indices of the other optic */ - final def composeWithRightIndex[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { + final def andThenWithRightIndex[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = new IndexedFold_[J, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], J, C, D]): Forget[R, S, T] = { val runForget = other(indexed).runForget @@ -453,10 +453,10 @@ abstract class IndexedTraversal_[I, S, T, A, B] extends Serializable { self => } /** compose [[IndexedTraversal_]] with an [[IndexedFold_]], while preserving the indices of the other optic */ - final def *>>[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = composeWithRightIndex(other) + final def *>>[J, C, D](other: IndexedFold_[J, A, B, C, D]): IndexedFold_[J, S, T, C, D] = andThenWithRightIndex(other) /** compose [[IndexedTraversal_]] with an [[IndexedFold_]], while preserving self indices */ - final def composeWithLeftIndex[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + final def andThenWithLeftIndex[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_) { case (a, i) => other.foldMap(a) { case (c, _) => indexed.runIndex.runForget((c, i)) } @@ -464,7 +464,7 @@ abstract class IndexedTraversal_[I, S, T, A, B] extends Serializable { self => } /** compose [[IndexedTraversal_]] with an [[IndexedFold_]], while preserving self indices */ - final def <<*[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = composeWithLeftIndex(other) + final def <<*[C, D](other: IndexedFold_[_, A, B, C, D]): IndexedFold_[I, S, T, C, D] = andThenWithLeftIndex(other) private def minMax(s: S)(f: (A, A) => A): Option[A] = foldRight[Option[A]](s)(None)((pair, op) => f(pair._1, op.getOrElse(pair._1)).some) diff --git a/core/shared/src/main/scala/proptics/Iso.scala b/core/shared/src/main/scala/proptics/Iso.scala index 2276d9918..1de091b83 100644 --- a/core/shared/src/main/scala/proptics/Iso.scala +++ b/core/shared/src/main/scala/proptics/Iso.scala @@ -81,28 +81,28 @@ abstract class Iso_[S, T, A, B] extends Serializable { self => self(Re(identity[P[B, A]])).runRe(pab) } - /** compose this [[Iso_]] with a function lifted to a [[Getter_]], having this [[Iso_]] applied last */ - final def to[C, D](f: A => C): Getter_[S, T, C, D] = compose(Getter_[A, B, C, D](f)) + /** compose this [[Iso_]] with a function lifted to a [[Getter_]], having this [[Iso_]] applied first */ + final def to[C, D](f: A => C): Getter_[S, T, C, D] = andThen(Getter_[A, B, C, D](f)) - /** compose this [[Iso_]] with an [[Iso_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): Iso_[S, T, C, D] = new Iso_[S, T, C, D] { + /** compose this [[Iso_]] with an [[Iso_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): Iso_[S, T, C, D] = new Iso_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Profunctor[P]): P[S, T] = self(other(pab)) } - /** compose this [[Iso_]] with an [[Iso_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): Iso_[C, D, A, B] = new Iso_[C, D, A, B] { + /** compose this [[Iso_]] with an [[Iso_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): Iso_[C, D, A, B] = new Iso_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Profunctor[P]): P[C, D] = other(self(pab)) } - /** compose this [[Iso_]] with an [[AnIso_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): AnIso_[S, T, C, D] = new AnIso_[S, T, C, D] { + /** compose this [[Iso_]] with an [[AnIso_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): AnIso_[S, T, C, D] = new AnIso_[S, T, C, D] { override private[proptics] def apply(exchange: Exchange[C, D, C, D]): Exchange[C, D, S, T] = self(other(exchange)) override def review(d: D): T = self.review(other.review(d)) } - /** compose this [[Iso_]] with an [[AnIso_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): AnIso_[C, D, A, B] = new AnIso_[C, D, A, B] { + /** compose this [[Iso_]] with an [[AnIso_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): AnIso_[C, D, A, B] = new AnIso_[C, D, A, B] { override private[proptics] def apply(exchange: Exchange[A, B, A, B]): Exchange[A, B, C, D] = Exchange(self.view _ compose other.view, other.review _ compose self.review) @@ -110,43 +110,43 @@ abstract class Iso_[S, T, A, B] extends Serializable { self => override def review(b: B): D = other.review(self.review(b)) } - /** compose this [[Iso_]] with a [[Lens_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): Lens_[S, T, C, D] = new Lens_[S, T, C, D] { + /** compose this [[Iso_]] with a [[Lens_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): Lens_[S, T, C, D] = new Lens_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Strong[P]): P[S, T] = self(other(pab)) } - /** compose this [[Iso_]] with a [[Lens_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): Lens_[C, D, A, B] = new Lens_[C, D, A, B] { + /** compose this [[Iso_]] with a [[Lens_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): Lens_[C, D, A, B] = new Lens_[C, D, A, B] { override def apply[P[_, _]](pab: P[A, B])(implicit ev: Strong[P]): P[C, D] = other(self(pab)) } - /** compose this [[Iso_]] with an [[ALens_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): ALens_[S, T, C, D] = new ALens_[S, T, C, D] { + /** compose this [[Iso_]] with an [[ALens_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): ALens_[S, T, C, D] = new ALens_[S, T, C, D] { override def apply(shop: Shop[C, D, C, D]): Shop[C, D, S, T] = self(other(shop)) } - /** compose this [[Iso_]] with an [[ALens_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): ALens_[C, D, A, B] = + /** compose this [[Iso_]] with an [[ALens_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): ALens_[C, D, A, B] = ALens_(self.view _ compose other.view)(c => b => other.over(self.set(b))(c)) - /** compose this [[Iso_]] with a [[Prism_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): Prism_[S, T, C, D] = new Prism_[S, T, C, D] { + /** compose this [[Iso_]] with a [[Prism_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): Prism_[S, T, C, D] = new Prism_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Choice[P]): P[S, T] = self(other(pab)) /** view the focus of a [[Prism_]] or return the modified source of a [[Prism_]] */ override def viewOrModify(s: S): Either[T, C] = other.viewOrModify(self.view(s)).leftMap(self.set(_)(s)) } - /** compose this [[Iso_]] with a [[Prism_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): Prism_[C, D, A, B] = new Prism_[C, D, A, B] { + /** compose this [[Iso_]] with a [[Prism_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): Prism_[C, D, A, B] = new Prism_[C, D, A, B] { override def apply[P[_, _]](pab: P[A, B])(implicit ev: Choice[P]): P[C, D] = other(self(pab)) /** view the focus of a [[Prism_]] or return the modified source of a [[Prism_]] */ override def viewOrModify(c: C): Either[D, A] = other.viewOrModify(c).map(self.view) } - /** compose this [[Iso_]] with an [[APrism_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): APrism_[S, T, C, D] = new APrism_[S, T, C, D] { + /** compose this [[Iso_]] with an [[APrism_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): APrism_[S, T, C, D] = new APrism_[S, T, C, D] { override private[proptics] def apply(market: Market[C, D, C, D]): Market[C, D, S, T] = self(other(market)) override def traverse[F[_]](s: S)(f: C => F[D])(implicit ev: Applicative[F]): F[T] = { @@ -156,8 +156,8 @@ abstract class Iso_[S, T, A, B] extends Serializable { self => } } - /** compose this [[Iso_]] with an [[APrism_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): APrism_[C, D, A, B] = new APrism_[C, D, A, B] { + /** compose this [[Iso_]] with an [[APrism_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): APrism_[C, D, A, B] = new APrism_[C, D, A, B] { override private[proptics] def apply(market: Market[A, B, A, B]): Market[A, B, C, D] = Market(other.viewOrModify(_).map(self.view), other.review _ compose self.review) @@ -166,16 +166,16 @@ abstract class Iso_[S, T, A, B] extends Serializable { self => other.traverse[F](c)(self.overF(f)) } - /** compose this [[Iso_]] with an [[AffineTraversal_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { + /** compose this [[Iso_]] with an [[AffineTraversal_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev0: Choice[P], ev1: Strong[P]): P[S, T] = self(other(pab))(ev1) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ override def viewOrModify(s: S): Either[T, C] = other.viewOrModify(self.view(s)).leftMap(self.set(_)(s)) } - /** compose this [[Iso_]] with an [[AffineTraversal_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { + /** compose this [[Iso_]] with an [[AffineTraversal_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev0: Choice[P], ev1: Strong[P]): P[C, D] = other(self(pab)(ev1)) @@ -183,159 +183,159 @@ abstract class Iso_[S, T, A, B] extends Serializable { self => override def viewOrModify(c: C): Either[D, A] = other.viewOrModify(c).map(self.view) } - /** compose this [[Iso_]] with an [[AnAffineTraversal_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[Iso_]] with an [[AnAffineTraversal_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_ { s: S => other.viewOrModify(self.view(s)).leftMap(self.set(_)(s)) } { s => d => self.over(other.set(d))(s) } - /** compose this [[Iso_]] with an [[AnAffineTraversal_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[Iso_]] with an [[AnAffineTraversal_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_(other.viewOrModify(_: C).map(self.view))(c => b => other.over(self.set(b))(c)) - /** compose this [[Iso_]] with a [[Traversal_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { + /** compose this [[Iso_]] with a [[Traversal_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Wander[P]): P[S, T] = self(other(pab)) } - /** compose this [[Iso_]] with a [[Traversal_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { + /** compose this [[Iso_]] with a [[Traversal_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Wander[P]): P[C, D] = other(self(pab)) } - /** compose this [[Iso_]] with an [[ATraversal_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[Iso_]] with an [[ATraversal_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.traverse(_)(pafb)) }) - /** compose this [[Iso_]] with an [[ATraversal_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[Iso_]] with an [[ATraversal_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse[F](c)(self.overF(pafb)) }) - /** compose this [[Iso_]] with a [[Setter_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Iso_]] with a [[Setter_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[Iso_]] with a [[Setter_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Iso_]] with a [[Setter_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Iso_]] with a [[Getter_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { + /** compose this [[Iso_]] with a [[Getter_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { override private[proptics] def apply(forget: Forget[C, C, D]): Forget[C, S, T] = self(other(forget))(profunctorForget[C]) } - /** compose this [[Iso_]] with a [[Getter_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { + /** compose this [[Iso_]] with a [[Getter_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { override private[proptics] def apply(forget: Forget[A, A, B]): Forget[A, C, D] = { val forgetT = self(forget)(profunctorForget[A]) Forget(forgetT.runForget compose other.view) } } - /** compose this [[Iso_]] with a [[Fold_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Iso_]] with a [[Fold_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s))(forget.runForget)) } - /** compose this [[Iso_]] with a [[Fold_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Iso_]] with a [[Fold_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(forget.runForget compose self.view)) } - /** compose this [[Iso_]] with a [[Grate_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: Grate_[A, B, C, D]): Grate_[S, T, C, D] = new Grate_[S, T, C, D] { + /** compose this [[Iso_]] with a [[Grate_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: Grate_[A, B, C, D]): Grate_[S, T, C, D] = new Grate_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Closed[P]): P[S, T] = self(other(pab)) } - /** compose this [[Iso_]] with a [[Grate_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: Grate_[C, D, S, T]): Grate_[C, D, A, B] = new Grate_[C, D, A, B] { + /** compose this [[Iso_]] with a [[Grate_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: Grate_[C, D, S, T]): Grate_[C, D, A, B] = new Grate_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Closed[P]): P[C, D] = other(self(pab)) } - /** compose this [[Iso_]] with a [[Review_]], having this [[Iso_]] applied last */ - final def compose[C, D](other: Review_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { + /** compose this [[Iso_]] with a [[Review_]], having this [[Iso_]] applied first */ + final def andThen[C, D](other: Review_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { override private[proptics] def apply(tagged: Tagged[C, D]): Tagged[S, T] = Tagged(self.review(other.review(tagged.runTag))) } - /** compose this [[Iso_]] with a [[Review_]], having this [[Iso_]] applied first */ - final def andThen[C, D](other: Review_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { + /** compose this [[Iso_]] with a [[Review_]], having this [[Iso_]] applied last */ + final def compose[C, D](other: Review_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { override private[proptics] def apply(tagged: Tagged[A, B]): Tagged[C, D] = Tagged(other.review(self.review(tagged.runTag))) } - /** compose this [[Iso_]] with an [[IndexedLens_]], having this [[Iso_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedLens_[I, S, T, C, D] = + /** compose this [[Iso_]] with an [[IndexedLens_]], having this [[Iso_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedLens_[I, S, T, C, D] = IndexedLens_((s: S) => other.view(self.view(s)))(s => d => self.set(other.set(d)(self.view(s)))(s)) - /** compose this [[Iso_]] with an [[IndexedLens_]], having this [[Iso_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedLens_[I, C, D, A, B] = + /** compose this [[Iso_]] with an [[IndexedLens_]], having this [[Iso_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedLens_[I, C, D, A, B] = IndexedLens_((c: C) => other.view(c).leftMap(self.view))(c => b => other.over { case (s, _) => self.set(b)(s) }(c)) - /** compose this [[Iso_]] with an [[AnIndexedLens_]], having this [[Iso_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = + /** compose this [[Iso_]] with an [[AnIndexedLens_]], having this [[Iso_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = AnIndexedLens_((s: S) => other.view(self.view(s)))(s => d => self.set(other.set(d)(self.view(s)))(s)) - /** compose this [[Iso_]] with an [[AnIndexedLens_]], having this [[Iso_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = + /** compose this [[Iso_]] with an [[AnIndexedLens_]], having this [[Iso_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = AnIndexedLens_((c: C) => other.view(c).leftMap(self.view))(c => b => other.over { case (s, _) => self.set(b)(s) }(c)) - /** compose this [[Iso_]] with an [[IndexedTraversal_]], having this [[Iso_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[Iso_]] with an [[IndexedTraversal_]], having this [[Iso_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.traverse(_)(other.traverse(_)(f)) }) - /** compose this [[Iso_]] with an [[IndexedTraversal_]], having this [[Iso_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[Iso_]] with an [[IndexedTraversal_]], having this [[Iso_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[Iso_]] with an [[IndexedFold_]], having this [[Iso_]] applied last */ - final def compose[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[Iso_]] with an [[IndexedFold_]], having this [[Iso_]] applied first */ + final def andThen[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = s => self.set(other.over(indexed.runIndex)(self.view(s)))(s) } - /** compose this [[Iso_]] with an [[IndexedFold_]], having this [[Iso_]] applied first */ - final def andThen[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[Iso_]] with an [[IndexedFold_]], having this [[Iso_]] applied last */ + final def compose[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[Function, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[Iso_]] with an [[IndexedGetter_]], having this [[Iso_]] applied last */ - final def compose[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Iso_]] with an [[IndexedGetter_]], having this [[Iso_]] applied first */ + final def andThen[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(indexed.runIndex.runForget compose other.view compose self.view) } - /** compose this [[Iso_]] with an [[IndexedGetter_]], having this [[Iso_]] applied first */ - final def andThen[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Iso_]] with an [[IndexedGetter_]], having this [[Iso_]] applied last */ + final def compose[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(c => indexed.runIndex.runForget(other.view(c).leftMap(self.view))) } - /** compose this [[Iso_]] with an [[IndexedFold_]], having this [[Iso_]] applied last */ - final def compose[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Iso_]] with an [[IndexedFold_]], having this [[Iso_]] applied first */ + final def andThen[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s))(indexed.runIndex.runForget)) } - /** compose this [[Iso_]] with an [[IndexedFold_]], having this [[Iso_]] applied first */ - final def andThen[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Iso_]] with an [[IndexedFold_]], having this [[Iso_]] applied last */ + final def compose[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => indexed.runIndex.runForget((self.view(s), i)) }) } diff --git a/core/shared/src/main/scala/proptics/Lens.scala b/core/shared/src/main/scala/proptics/Lens.scala index 64d92a1db..fe98ded38 100644 --- a/core/shared/src/main/scala/proptics/Lens.scala +++ b/core/shared/src/main/scala/proptics/Lens.scala @@ -94,210 +94,210 @@ abstract class Lens_[S, T, A, B] extends Serializable { self => /** transform a [[Lens_]] to an [[ALens_]] */ final def asALens: ALens_[S, T, A, B] = ALens_.lens[S, T, A, B](self.view)(set _ flip _) - /** compose this [[Lens_]] with a function lifted to a [[Getter_]], having this [[Lens_]] applied last */ - final def to[C, D](f: A => C): Getter_[S, T, C, D] = compose(Getter_[A, B, C, D](f)) + /** compose this [[Lens_]] with a function lifted to a [[Getter_]], having this [[Lens_]] applied first */ + final def to[C, D](f: A => C): Getter_[S, T, C, D] = andThen(Getter_[A, B, C, D](f)) - /** compose this [[Lens_]] with an [[Iso_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): Lens_[S, T, C, D] = new Lens_[S, T, C, D] { + /** compose this [[Lens_]] with an [[Iso_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): Lens_[S, T, C, D] = new Lens_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev: Strong[P]): P[S, T] = self(other(pab)) } - /** compose this [[Lens_]] with an [[Iso_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): Lens_[C, D, A, B] = new Lens_[C, D, A, B] { + /** compose this [[Lens_]] with an [[Iso_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): Lens_[C, D, A, B] = new Lens_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Strong[P]): P[C, D] = other(self(pab)) } - /** compose this [[Lens_]] with an [[AnIso_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): Lens_[S, T, C, D] = + /** compose this [[Lens_]] with an [[AnIso_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): Lens_[S, T, C, D] = Lens_(other.view _ compose self.view)(s => d => self.set(other.review(d))(s)) - /** compose this [[Lens_]] with an [[Iso_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): Lens_[C, D, A, B] = + /** compose this [[Lens_]] with an [[Iso_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): Lens_[C, D, A, B] = Lens_(self.view _ compose other.view)(c => b => other.review(self.set(b)(other.view(c)))) - /** compose this [[Lens_]] with a [[Lens_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): Lens_[S, T, C, D] = new Lens_[S, T, C, D] { + /** compose this [[Lens_]] with a [[Lens_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): Lens_[S, T, C, D] = new Lens_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev: Strong[P]): P[S, T] = self(other(pab)) } - /** compose this [[Lens_]] with a [[Lens_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): Lens_[C, D, A, B] = new Lens_[C, D, A, B] { + /** compose this [[Lens_]] with a [[Lens_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): Lens_[C, D, A, B] = new Lens_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Strong[P]): P[C, D] = other(self(pab)) } - /** compose this [[Lens_]] with an [[ALens_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): ALens_[S, T, C, D] = new ALens_[S, T, C, D] { + /** compose this [[Lens_]] with an [[ALens_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): ALens_[S, T, C, D] = new ALens_[S, T, C, D] { override def apply(shop: Shop[C, D, C, D]): Shop[C, D, S, T] = self(other(shop)) } - /** compose this [[Lens_]] with an [[ALens_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): ALens_[C, D, A, B] = + /** compose this [[Lens_]] with an [[ALens_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): ALens_[C, D, A, B] = ALens_(self.view _ compose other.view)(c => b => other.over(self.set(b))(c)) - /** compose this [[Lens_]] with a [[Prism_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { + /** compose this [[Lens_]] with a [[Prism_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev0: Choice[P], ev1: Strong[P]): P[S, T] = self(other(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ override def viewOrModify(s: S): Either[T, C] = other.viewOrModify(self.view(s)).leftMap(self.set(_)(s)) } - /** compose this [[Lens_]] with a [[Prism_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { + /** compose this [[Lens_]] with a [[Prism_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev0: Choice[P], ev1: Strong[P]): P[C, D] = other(self(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ override def viewOrModify(c: C): Either[D, A] = other.viewOrModify(c).map(self.view) } - /** compose this [[Lens_]] with an [[APrism_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): AffineTraversal_[S, T, C, D] = + /** compose this [[Lens_]] with an [[APrism_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): AffineTraversal_[S, T, C, D] = AffineTraversal_ { s: S => other.viewOrModify(self.view(s)).leftMap(self.set(_)(s)) } { s => d => self.set(other.set(d)(self.view(s)))(s) } - /** compose this [[Lens_]] with an [[APrism_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): AffineTraversal_[C, D, A, B] = + /** compose this [[Lens_]] with an [[APrism_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): AffineTraversal_[C, D, A, B] = AffineTraversal_((c: C) => other.viewOrModify(c).map(self.view))(c => b => other.over(self.set(b))(c)) - /** compose this [[Lens_]] with a [[AffineTraversal_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { + /** compose this [[Lens_]] with a [[AffineTraversal_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev0: Choice[P], ev1: Strong[P]): P[S, T] = self(other(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ override def viewOrModify(s: S): Either[T, C] = other.viewOrModify(self.view(s)).leftMap(self.set(_)(s)) } - /** compose this [[Lens_]] with a [[AffineTraversal_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { + /** compose this [[Lens_]] with a [[AffineTraversal_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev0: Choice[P], ev1: Strong[P]): P[C, D] = other(self(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ override def viewOrModify(c: C): Either[D, A] = other.viewOrModify(c).map(self.view) } - /** compose this [[Lens_]] with an [[AnAffineTraversal_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[Lens_]] with an [[AnAffineTraversal_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_ { s: S => other.viewOrModify(self.view(s)).leftMap(self.set(_)(s)) } { s => d => self.over(other.set(d))(s) } - /** compose this [[Lens_]] with an [[AnAffineTraversal_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[Lens_]] with an [[AnAffineTraversal_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_ { c: C => other.viewOrModify(c).map(self.view) }(c => b => other.over(self.set(b))(c)) - /** compose this [[Lens_]] with a [[Traversal_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { + /** compose this [[Lens_]] with a [[Traversal_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Wander[P]): P[S, T] = self(other(pab)) } - /** compose this [[Lens_]] with a [[Traversal_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { + /** compose this [[Lens_]] with a [[Traversal_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Wander[P]): P[C, D] = other(self(pab)) } - /** compose this [[Lens_]] with an [[ATraversal_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { + /** compose this [[Lens_]] with an [[ATraversal_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.traverse(_)(pafb)) }) - /** compose this [[Lens_]] with an [[ATraversal_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { + /** compose this [[Lens_]] with an [[ATraversal_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse[F](c)(self.overF(pafb)) }) - /** compose this [[Lens_]] with a [[Setter_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Lens_]] with a [[Setter_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[Lens_]] with a [[Setter_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Lens_]] with a [[Setter_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other(self(pab)) } - /** compose this [[Lens_]] with a [[Getter_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { + /** compose this [[Lens_]] with a [[Getter_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Getter_[S, T, C, D] = new Getter_[S, T, C, D] { override private[proptics] def apply(forget: Forget[C, C, D]): Forget[C, S, T] = self(other(Forget(identity))) } - /** compose this [[Lens_]] with a [[Getter_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { + /** compose this [[Lens_]] with a [[Getter_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Getter_[C, D, A, B] = new Getter_[C, D, A, B] { override private[proptics] def apply(forget: Forget[A, A, B]): Forget[A, C, D] = Forget(c => self(forget).runForget(other.view(c))) } - /** compose this [[Lens_]] with a [[Fold_]], having this [[Lens_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Lens_]] with a [[Fold_]], having this [[Lens_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = self(other(forget)) } - /** compose this [[Lens_]] with a [[Fold_]], having this [[Lens_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Lens_]] with a [[Fold_]], having this [[Lens_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(other.foldMap(_)(forget.runForget compose self.view)) } - /** compose this [[Lens_]] with an [[IndexedLens_]], having this [[Lens_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedLens_[I, S, T, C, D] = + /** compose this [[Lens_]] with an [[IndexedLens_]], having this [[Lens_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedLens_[I, S, T, C, D] = IndexedLens_((s: S) => other.view(self.view(s)))(s => d => self.set(other.set(d)(self.view(s)))(s)) - /** compose this [[Lens_]] with an [[IndexedLens_]], having this [[Lens_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedLens_[I, C, D, A, B] = + /** compose this [[Lens_]] with an [[IndexedLens_]], having this [[Lens_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedLens_[I, C, D, A, B] = IndexedLens_((c: C) => other.view(c).leftMap(self.view))(c => b => other.over { case (s, _) => self.set(b)(s) }(c)) - /** compose this [[Lens_]] with an [[AnIndexedLens_]], having this [[Lens_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = + /** compose this [[Lens_]] with an [[AnIndexedLens_]], having this [[Lens_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): AnIndexedLens_[I, S, T, C, D] = AnIndexedLens_((s: S) => other.view(self.view(s)))(s => d => self.set(other.set(d)(self.view(s)))(s)) - /** compose this [[Lens_]] with an [[AnIndexedLens_]], having this [[Lens_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = + /** compose this [[Lens_]] with an [[AnIndexedLens_]], having this [[Lens_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): AnIndexedLens_[I, C, D, A, B] = AnIndexedLens_((c: C) => other.view(c).leftMap(self.view))(c => b => other.over { case (s, _) => self.set(b)(s) }(c)) - /** compose this [[Lens_]] with an [[IndexedTraversal_]], having this [[Lens_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[Lens_]] with an [[IndexedTraversal_]], having this [[Lens_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[Lens_]] with an [[IndexedTraversal_]], having this [[Lens_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[Lens_]] with an [[IndexedTraversal_]], having this [[Lens_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[Lens_]] with an [[IndexedSetter_]], having this [[Lens_]] applied last */ - final def compose[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[Lens_]] with an [[IndexedSetter_]], having this [[Lens_]] applied first */ + final def andThen[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = s => self.set(other.over { case (c, i) => indexed.runIndex((c, i)) }(self.view(s)))(s) } - /** compose this [[Lens_]] with an [[IndexedFold_]], having this [[Lens_]] applied first */ - final def andThen[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[Lens_]] with an [[IndexedFold_]], having this [[Lens_]] applied last */ + final def compose[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[Function, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[Lens_]] with an [[IndexedGetter_]], having this [[Lens_]] applied last */ - final def compose[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Lens_]] with an [[IndexedGetter_]], having this [[Lens_]] applied first */ + final def andThen[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(indexed.runIndex.runForget compose other.view compose self.view) } - /** compose this [[Lens_]] with an [[IndexedGetter_]], having this [[Lens_]] applied first */ - final def andThen[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Lens_]] with an [[IndexedGetter_]], having this [[Lens_]] applied last */ + final def compose[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(c => indexed.runIndex.runForget(other.view(c).leftMap(self.view))) } - /** compose this [[Lens_]] with an [[IndexedFold_]], having this [[Lens_]] applied last */ - final def compose[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Lens_]] with an [[IndexedFold_]], having this [[Lens_]] applied first */ + final def andThen[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(s => other.foldMap(self.view(s))(indexed.runIndex.runForget)) } - /** compose this [[Lens_]] with an [[IndexedFold_]], having this [[Lens_]] applied first */ - final def andThen[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Lens_]] with an [[IndexedFold_]], having this [[Lens_]] applied last */ + final def compose[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => indexed.runIndex.runForget((self.view(s), i)) }) } diff --git a/core/shared/src/main/scala/proptics/Prism.scala b/core/shared/src/main/scala/proptics/Prism.scala index db7de63e4..6f7a93461 100644 --- a/core/shared/src/main/scala/proptics/Prism.scala +++ b/core/shared/src/main/scala/proptics/Prism.scala @@ -97,63 +97,63 @@ abstract class Prism_[S, T, A, B] extends Serializable { self => Forget(self.preview(_).fold(Monoid[R].empty)(forget.runForget)) } - /** compose this [[Prism_]] with a function lifted to a [[Getter_]], having this [[Prism_]] applied last */ - final def to[C, D](f: A => C): Fold_[S, T, C, D] = compose(Getter_[A, B, C, D](f)) + /** compose this [[Prism_]] with a function lifted to a [[Getter_]], having this [[Prism_]] applied first */ + final def to[C, D](f: A => C): Fold_[S, T, C, D] = andThen(Getter_[A, B, C, D](f)) - /** compose this [[Prism_]] with an [[Iso_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): Prism_[S, T, C, D] = new Prism_[S, T, C, D] { + /** compose this [[Prism_]] with an [[Iso_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): Prism_[S, T, C, D] = new Prism_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev: Choice[P]): P[S, T] = self(other(pab)) /** view the focus of a [[Prism_]] or return the modified source of a [[Prism_]] */ override def viewOrModify(s: S): Either[T, C] = self.viewOrModify(s).map(other.view) } - /** compose this [[Prism_]] with an [[Iso_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): Prism_[C, D, A, B] = new Prism_[C, D, A, B] { + /** compose this [[Prism_]] with an [[Iso_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): Prism_[C, D, A, B] = new Prism_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Choice[P]): P[C, D] = other(self(pab)) /** view the focus of a [[Prism_]] or return the modified source of a [[Prism_]] */ override def viewOrModify(c: C): Either[D, A] = self.viewOrModify(other.view(c)).leftMap(other.review) } - /** compose this [[Prism_]] with an [[AnIso_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): Prism_[S, T, C, D] = + /** compose this [[Prism_]] with an [[AnIso_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): Prism_[S, T, C, D] = Prism_((s: S) => self.viewOrModify(s).map(other.view))(self.review _ compose other.review) - /** compose this [[Prism_]] with an [[AnIso_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): Prism_[C, D, A, B] = + /** compose this [[Prism_]] with an [[AnIso_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): Prism_[C, D, A, B] = Prism_((c: C) => self.viewOrModify(other.view(c)).leftMap(other.review))(other.review _ compose self.review) - /** compose this [[Prism_]] with a [[Lens_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { + /** compose this [[Prism_]] with a [[Lens_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev0: Choice[P], ev1: Strong[P]): P[S, T] = self(other(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ override def viewOrModify(s: S): Either[T, C] = self.viewOrModify(s).map(other.view) } - /** compose this [[Prism_]] with a [[Lens_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { + /** compose this [[Prism_]] with a [[Lens_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev0: Choice[P], ev1: Strong[P]): P[C, D] = other(self(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ override def viewOrModify(c: C): Either[D, A] = self.viewOrModify(other.view(c)).leftMap(t => other.set(t)(c)) } - /** compose this [[Prism_]] with an [[ALens_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): AffineTraversal_[S, T, C, D] = + /** compose this [[Prism_]] with an [[ALens_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): AffineTraversal_[S, T, C, D] = AffineTraversal_ { s: S => self.viewOrModify(s).map(other.view) } { s => d => self.over(a => other.set(d)(a))(s) } - /** compose this [[Prism_]] with an [[ALens_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): AffineTraversal_[C, D, A, B] = + /** compose this [[Prism_]] with an [[ALens_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): AffineTraversal_[C, D, A, B] = AffineTraversal_ { c: C => self.viewOrModify(other.view(c)).leftMap(other.set(_)(c)) } { c => b => other.over(a => self.set(b)(a))(c) } - /** compose this [[Prism_]] with a [[Prism_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): Prism_[S, T, C, D] = new Prism_[S, T, C, D] { + /** compose this [[Prism_]] with a [[Prism_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): Prism_[S, T, C, D] = new Prism_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev: Choice[P]): P[S, T] = self(other(pab)) /** view the focus of a [[Prism_]] or return the modified source of a [[Prism_]] */ @@ -161,8 +161,8 @@ abstract class Prism_[S, T, A, B] extends Serializable { self => self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) } - /** compose this [[Prism_]] with a [[Prism_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): Prism_[C, D, A, B] = new Prism_[C, D, A, B] { + /** compose this [[Prism_]] with a [[Prism_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): Prism_[C, D, A, B] = new Prism_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Choice[P]): P[C, D] = other(self(pab)) /** view the focus of a [[Prism_]] or return the modified source of a [[Prism_]] */ @@ -170,16 +170,16 @@ abstract class Prism_[S, T, A, B] extends Serializable { self => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.review)) } - /** compose this [[Prism_]] with an [[APrism_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): APrism_[S, T, C, D] = new APrism_[S, T, C, D] { + /** compose this [[Prism_]] with an [[APrism_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): APrism_[S, T, C, D] = new APrism_[S, T, C, D] { override private[proptics] def apply(market: Market[C, D, C, D]): Market[C, D, S, T] = self(other(market)) override def traverse[F[_]](s: S)(f: C => F[D])(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.traverse(_)(f)) } - /** compose this [[Prism_]] with an [[APrism_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): APrism_[C, D, A, B] = new APrism_[C, D, A, B] { + /** compose this [[Prism_]] with an [[APrism_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): APrism_[C, D, A, B] = new APrism_[C, D, A, B] { override private[proptics] def apply(market: Market[A, B, A, B]): Market[A, B, C, D] = Market(other.viewOrModify(_).flatMap(self.viewOrModify(_).leftMap(other.review)), other.review _ compose self.review) @@ -188,8 +188,8 @@ abstract class Prism_[S, T, A, B] extends Serializable { self => other.traverse(s)(self.traverse(_)(f)) } - /** compose this [[Prism_]] with an [[AffineTraversal_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { + /** compose this [[Prism_]] with an [[AffineTraversal_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): AffineTraversal_[S, T, C, D] = new AffineTraversal_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev0: Choice[P], ev1: Strong[P]): P[S, T] = self(other(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ @@ -197,8 +197,8 @@ abstract class Prism_[S, T, A, B] extends Serializable { self => self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) } - /** compose this [[Prism_]] with an [[AffineTraversal_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { + /** compose this [[Prism_]] with an [[AffineTraversal_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): AffineTraversal_[C, D, A, B] = new AffineTraversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev0: Choice[P], ev1: Strong[P]): P[C, D] = other(self(pab)) /** view the focus of an [[AffineTraversal_]] or return the modified source of an [[AffineTraversal_]] */ @@ -206,26 +206,26 @@ abstract class Prism_[S, T, A, B] extends Serializable { self => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.set(_)(c))) } - /** compose this [[Prism_]] with an [[AffineTraversal_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = + /** compose this [[Prism_]] with an [[AffineTraversal_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): AnAffineTraversal_[S, T, C, D] = AnAffineTraversal_ { s: S => self.viewOrModify(s).flatMap(other.viewOrModify(_).leftMap(self.set(_)(s))) }(s => d => self.over(other.set(d))(s)) - /** compose this [[Prism_]] with an [[AffineTraversal_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = + /** compose this [[Prism_]] with an [[AffineTraversal_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): AnAffineTraversal_[C, D, A, B] = AnAffineTraversal_ { c: C => other.viewOrModify(c).flatMap(self.viewOrModify(_).leftMap(other.set(_)(c))) }(c => b => other.over(self.set(b))(c)) - /** compose this [[Prism_]] with a [[Traversal_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { + /** compose this [[Prism_]] with a [[Traversal_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev: Wander[P]): P[S, T] = self(other(pab)) } - /** compose this [[Prism_]] with a [[Traversal_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { + /** compose this [[Prism_]] with a [[Traversal_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Wander[P]): P[C, D] = other(self(pab)) } - /** compose this [[Prism_]] with an [[ATraversal_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { + /** compose this [[Prism_]] with an [[ATraversal_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = { val bazaar = other(new Bazaar[* => *, C, D, C, D] { override def runBazaar: RunBazaar[* => *, C, D, C, D] = new RunBazaar[* => *, C, D, C, D] { @@ -237,8 +237,8 @@ abstract class Prism_[S, T, A, B] extends Serializable { self => } }) - /** compose this [[Prism_]] with an [[ATraversal_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { + /** compose this [[Prism_]] with an [[ATraversal_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = { val bazaar: Bazaar[* => *, S, T, C, D] = other(new Bazaar[* => *, S, T, S, T] { override def runBazaar: RunBazaar[* => *, S, T, S, T] = new RunBazaar[* => *, S, T, S, T] { @@ -250,110 +250,110 @@ abstract class Prism_[S, T, A, B] extends Serializable { self => } }) - /** compose this [[Prism_]] with a [[Setter_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Prism_]] with a [[Setter_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[Prism_]] with a [[Setter_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Prism_]] with a [[Setter_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other(self(pab)) } - /** compose this [[Prism_]] with a [[Getter_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Prism_]] with a [[Getter_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.viewOrModify(_).fold(const(Monoid[R].empty), forget.runForget compose other.view)) } - /** compose this [[Prism_]] with a [[Getter_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Prism_]] with a [[Getter_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(c => self.viewOrModify(other.view(c)).fold[R](const(Monoid[R].empty), forget.runForget)) } - /** compose this [[Prism_]] with a [[Fold_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Prism_]] with a [[Fold_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override private[proptics] def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = self(other(forget)) } - /** compose this [[Prism_]] with a [[Fold_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Prism_]] with a [[Fold_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = other(self(forget)) } - /** compose this [[Prism_]] with a [[Review_]], having this [[Prism_]] applied last */ - final def compose[C, D](other: Review_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { + /** compose this [[Prism_]] with a [[Review_]], having this [[Prism_]] applied first */ + final def andThen[C, D](other: Review_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { override private[proptics] def apply(tagged: Tagged[C, D]): Tagged[S, T] = self(other(tagged)) } - /** compose this [[Prism_]] with a [[Review_]], having this [[Prism_]] applied first */ - final def andThen[C, D](other: Review_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { + /** compose this [[Prism_]] with a [[Review_]], having this [[Prism_]] applied last */ + final def compose[C, D](other: Review_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { override private[proptics] def apply(tagged: Tagged[A, B]): Tagged[C, D] = other(self(tagged)) } - /** compose this [[Prism_]] with an [[IndexedLens_]], having this [[Prism_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[Prism_]] with an [[IndexedLens_]], having this [[Prism_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[Prism_]] with an [[IndexedLens_]], having this [[Prism_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[Prism_]] with an [[IndexedLens_]], having this [[Prism_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF[F] { case (s, i) => self.overF(a => f((a, i)))(s) } }) - /** compose this [[Prism_]] with an [[AnIndexedLens_]], having this [[Prism_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[Prism_]] with an [[AnIndexedLens_]], having this [[Prism_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[Prism_]] with an [[AnIndexedLens_]], having this [[Prism_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[Prism_]] with an [[AnIndexedLens_]], having this [[Prism_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF[F] { case (s, i) => self.overF(a => f((a, i)))(s) } }) - /** compose this [[Prism_]] with an [[IndexedTraversal_]], having this [[Prism_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[Prism_]] with an [[IndexedTraversal_]], having this [[Prism_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.traverse(_)(other.traverse(_)(f)) }) - /** compose this [[Prism_]] with an [[IndexedTraversal_]], having this [[Prism_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[Prism_]] with an [[IndexedTraversal_]], having this [[Prism_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.traverse(_) { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[Prism_]] with an [[IndexedSetter_]], having this [[Prism_]] applied last */ - final def compose[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[Prism_]] with an [[IndexedSetter_]], having this [[Prism_]] applied first */ + final def andThen[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over(other.over(indexed.runIndex)) } - /** compose this [[Prism_]] with an [[IndexedSetter_]], having this [[Prism_]] applied first */ - final def andThen[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[Prism_]] with an [[IndexedSetter_]], having this [[Prism_]] applied last */ + final def compose[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[Function, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[Prism_]] with an [[IndexedGetter_]], having this [[Prism_]] applied last */ - final def compose[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Prism_]] with an [[IndexedGetter_]], having this [[Prism_]] applied first */ + final def andThen[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(indexed.runIndex.runForget compose other.view)) } - /** compose this [[Prism_]] with an [[IndexedGetter_]], having this [[Prism_]] applied first */ - final def andThen[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Prism_]] with an [[IndexedGetter_]], having this [[Prism_]] applied last */ + final def compose[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => val (s, i) = other.view(c) @@ -361,14 +361,14 @@ abstract class Prism_[S, T, A, B] extends Serializable { self => } } - /** compose this [[Prism_]] with an [[IndexedFold_]], having this [[Prism_]] applied last */ - final def compose[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Prism_]] with an [[IndexedFold_]], having this [[Prism_]] applied first */ + final def andThen[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.foldMap(_)(indexed.runIndex.runForget))) } - /** compose this [[Prism_]] with an [[IndexedFold_]], having this [[Prism_]] applied first */ - final def andThen[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Prism_]] with an [[IndexedFold_]], having this [[Prism_]] applied last */ + final def compose[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => self.foldMap(s)(a => indexed.runIndex.runForget((a, i))) }) } diff --git a/core/shared/src/main/scala/proptics/Review.scala b/core/shared/src/main/scala/proptics/Review.scala index aa11c672a..bbdd4abb3 100644 --- a/core/shared/src/main/scala/proptics/Review.scala +++ b/core/shared/src/main/scala/proptics/Review.scala @@ -22,70 +22,70 @@ abstract class Review_[S, T, A, B] extends Serializable { self => /** view the modified focus of a [[Review_]] in the state of a monad */ final def reuse(implicit ev: State[B, T]): State[B, T] = ev.inspect(review) - /** compose this [[Review_]] with an [[Iso_]], having this [[Review_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { + /** compose this [[Review_]] with an [[Iso_]], having this [[Review_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { override private[proptics] def apply(tagged: Tagged[C, D]): Tagged[S, T] = self(other(tagged)(Tagged.profunctorTagged)) } - /** compose this [[Review_]] with an [[Iso_]], having this [[Review_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { + /** compose this [[Review_]] with an [[Iso_]], having this [[Review_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { override private[proptics] def apply(tagged: Tagged[A, B]): Tagged[C, D] = Tagged(other.review(self.review(tagged.runTag))) } - /** compose this [[Review_]] with an [[AnIso_]], having this [[Review_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { + /** compose this [[Review_]] with an [[AnIso_]], having this [[Review_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { override private[proptics] def apply(tagged: Tagged[C, D]): Tagged[S, T] = Tagged(self.review(other.review(tagged.runTag))) } - /** compose this [[Review_]] with an [[AnIso_]], having this [[Review_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { + /** compose this [[Review_]] with an [[AnIso_]], having this [[Review_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { override private[proptics] def apply(tagged: Tagged[A, B]): Tagged[C, D] = Tagged(other.review(self.review(tagged.runTag))) } - /** compose this [[Review_]] with a [[Prism_]], having this [[Review_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { + /** compose this [[Review_]] with a [[Prism_]], having this [[Review_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { override private[proptics] def apply(tagged: Tagged[C, D]): Tagged[S, T] = self(other(tagged)) } - /** compose this [[Review_]] with a [[Prism_]], having this [[Review_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { + /** compose this [[Review_]] with a [[Prism_]], having this [[Review_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { override private[proptics] def apply(tagged: Tagged[A, B]): Tagged[C, D] = Tagged(other.review(self.review(tagged.runTag))) } - /** compose this [[Review_]] with an [[APrism_]], having this [[Review_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { + /** compose this [[Review_]] with an [[APrism_]], having this [[Review_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { override private[proptics] def apply(tagged: Tagged[C, D]): Tagged[S, T] = Tagged(self.review(other.review(tagged.runTag))) } - /** compose this [[Review_]] with an [[APrism_]], having this [[Review_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { + /** compose this [[Review_]] with an [[APrism_]], having this [[Review_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { override private[proptics] def apply(tagged: Tagged[A, B]): Tagged[C, D] = Tagged(other.review(self.review(tagged.runTag))) } - /** compose this [[Review_]] with a [[Grate_]], having this [[Review_]] applied last */ - final def compose[C, D](other: Grate_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { + /** compose this [[Review_]] with a [[Grate_]], having this [[Review_]] applied first */ + final def andThen[C, D](other: Grate_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { override private[proptics] def apply(tagged: Tagged[C, D]): Tagged[S, T] = self(other(tagged)) } - /** compose this [[Review_]] with a [[Grate_]], having this [[Review_]] applied first */ - final def andThen[C, D](other: Grate_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { + /** compose this [[Review_]] with a [[Grate_]], having this [[Review_]] applied last */ + final def compose[C, D](other: Grate_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { override private[proptics] def apply(tagged: Tagged[A, B]): Tagged[C, D] = Tagged(other.review(self.review(tagged.runTag))) } - /** compose this [[Review_]] with a [[Review_]], having this [[Review_]] applied last */ - final def compose[C, D](other: Review_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { + /** compose this [[Review_]] with a [[Review_]], having this [[Review_]] applied first */ + final def andThen[C, D](other: Review_[A, B, C, D]): Review_[S, T, C, D] = new Review_[S, T, C, D] { override private[proptics] def apply(tagged: Tagged[C, D]): Tagged[S, T] = self(other(tagged)) } - /** compose this [[Review_]] with a [[Review_]], having this [[Review_]] applied first */ - final def andThen[C, D](other: Review_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { + /** compose this [[Review_]] with a [[Review_]], having this [[Review_]] applied last */ + final def compose[C, D](other: Review_[C, D, S, T]): Review_[C, D, A, B] = new Review_[C, D, A, B] { override private[proptics] def apply(tagged: Tagged[A, B]): Tagged[C, D] = Tagged(other.review(self.review(tagged.runTag))) } diff --git a/core/shared/src/main/scala/proptics/Setter.scala b/core/shared/src/main/scala/proptics/Setter.scala index f5c5e2899..19bba81a7 100644 --- a/core/shared/src/main/scala/proptics/Setter.scala +++ b/core/shared/src/main/scala/proptics/Setter.scala @@ -21,170 +21,170 @@ abstract class Setter_[S, T, A, B] extends Serializable { self => /** modify the focus type of a [[Setter_]] using a function, resulting in a change of type to the full structure */ final def over(f: A => B): S => T = self(f) - /** compose this [[Setter_]] with an [[Iso_]], having this [[Setter_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Setter_]] with an [[Iso_]], having this [[Setter_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[Setter_]] with an [[Iso_]], having this [[Setter_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Setter_]] with an [[Iso_]], having this [[Setter_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other(self(pab)) } - /** compose this [[Setter_]] with an [[AnIso_]], having this [[Setter_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Setter_]] with an [[AnIso_]], having this [[Setter_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self.over(other.over(pab)) } - /** compose this [[Setter_]] with an [[AnIso_]], having this [[Setter_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Setter_]] with an [[AnIso_]], having this [[Setter_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Setter_]] with a [[Lens_]], having this [[Setter_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Setter_]] with a [[Lens_]], having this [[Setter_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[Setter_]] with a [[Lens_]], having this [[Setter_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Setter_]] with a [[Lens_]], having this [[Setter_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Setter_]] with an [[ALens_]], having this [[Setter_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Setter_]] with an [[ALens_]], having this [[Setter_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other.over(pab)) } - /** compose this [[Setter_]] with an [[ALens_]], having this [[Setter_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Setter_]] with an [[ALens_]], having this [[Setter_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Setter_]] with a [[Prism_]], having this [[Setter_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Setter_]] with a [[Prism_]], having this [[Setter_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[Setter_]] with a [[Prism_]], having this [[Setter_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Setter_]] with a [[Prism_]], having this [[Setter_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Setter_]] with an [[APrism_]], having this [[Setter_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Setter_]] with an [[APrism_]], having this [[Setter_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self.over(other.over(pab)) } - /** compose this [[Setter_]] with an [[APrism_]], having this [[Setter_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Setter_]] with an [[APrism_]], having this [[Setter_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Setter_]] with a [[AffineTraversal_]], having this [[Setter_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Setter_]] with a [[AffineTraversal_]], having this [[Setter_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[Setter_]] with a [[AffineTraversal_]], having this [[Setter_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Setter_]] with a [[AffineTraversal_]], having this [[Setter_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Setter_]] with an [[AnAffineTraversal_]], having this [[Setter_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Setter_]] with an [[AnAffineTraversal_]], having this [[Setter_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other.over(pab)) } - /** compose this [[Setter_]] with an [[AnAffineTraversal_]], having this [[Setter_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Setter_]] with an [[AnAffineTraversal_]], having this [[Setter_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Setter_]] with a [[Traversal_]], having this [[Setter_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Setter_]] with a [[Traversal_]], having this [[Setter_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[Setter_]] with a [[Traversal_]], having this [[Setter_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Setter_]] with a [[Traversal_]], having this [[Setter_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Setter_]] with an [[ATraversal_]], having this [[Setter_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Setter_]] with an [[ATraversal_]], having this [[Setter_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other.over(pab)) } - /** compose this [[Setter_]] with an [[ATraversal_]], having this [[Setter_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Setter_]] with an [[ATraversal_]], having this [[Setter_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Setter_]] with a [[Setter_]], having this [[Setter_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Setter_]] with a [[Setter_]], having this [[Setter_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[Setter_]] with a [[Setter_]], having this [[Setter_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Setter_]] with a [[Setter_]], having this [[Setter_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Setter_]] with a [[Grate_]], having this [[Setter_]] applied last */ - final def compose[C, D](other: Grate_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Setter_]] with a [[Grate_]], having this [[Setter_]] applied first */ + final def andThen[C, D](other: Grate_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[Setter_]] with a [[Grate_]], having this [[Setter_]] applied first */ - final def andThen[C, D](other: Grate_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Setter_]] with a [[Grate_]], having this [[Setter_]] applied last */ + final def compose[C, D](other: Grate_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other.over(self.over(pab)) } - /** compose this [[Setter_]] with an [[IndexedLens_]], having this [[Setter_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[Setter_]] with an [[IndexedLens_]], having this [[Setter_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over(other.over(indexed.runIndex)) } - /** compose this [[Setter_]] with an [[IndexedLens_]], having this [[Setter_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[Setter_]] with an [[IndexedLens_]], having this [[Setter_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[Setter_]] with an [[AnIndexedLens_]], having this [[Setter_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[Setter_]] with an [[AnIndexedLens_]], having this [[Setter_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over(other.over(indexed.runIndex)) } - /** compose this [[Setter_]] with an [[AnIndexedLens_]], having this [[Setter_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[Setter_]] with an [[AnIndexedLens_]], having this [[Setter_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[Setter_]] with an [[IndexedTraversal_]], having this [[Setter_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[Setter_]] with an [[IndexedTraversal_]], having this [[Setter_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self(other(Indexed(indexed.runIndex))) } - /** compose this [[Setter_]] with an [[IndexedTraversal_]], having this [[Setter_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[Setter_]] with an [[IndexedTraversal_]], having this [[Setter_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[Setter_]] with an [[IndexedTraversal_]], having this [[Setter_]] applied last */ - final def compose[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[Setter_]] with an [[IndexedTraversal_]], having this [[Setter_]] applied first */ + final def andThen[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self(other(Indexed(indexed.runIndex))) } - /** compose this [[Setter_]] with an [[IndexedTraversal_]], having this [[Setter_]] applied first */ - final def andThen[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[Setter_]] with an [[IndexedTraversal_]], having this [[Setter_]] applied last */ + final def compose[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[* => *, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } diff --git a/core/shared/src/main/scala/proptics/Traversal.scala b/core/shared/src/main/scala/proptics/Traversal.scala index 6eea52b41..37fca7ca5 100644 --- a/core/shared/src/main/scala/proptics/Traversal.scala +++ b/core/shared/src/main/scala/proptics/Traversal.scala @@ -186,223 +186,223 @@ abstract class Traversal_[S, T, A, B] extends Serializable { self => final def unsafePartsOf(implicit ev0: Sellable[* => *, Bazaar[* => *, *, *, Unit, *]], ev1: Aux[* => *, State[List[B], *]]): Lens_[S, T, List[A], List[B]] = Bazaar.unsafePartsOf(self.toBazaar) - /** compose this [[Traversal_]] with a function lifted to a [[Getter_]], having this [[Traversal_]] applied last */ - final def to[C, D](f: A => C): Fold_[S, T, C, D] = compose(Getter_[A, B, C, D](f)) + /** compose this [[Traversal_]] with a function lifted to a [[Getter_]], having this [[Traversal_]] applied first */ + final def to[C, D](f: A => C): Fold_[S, T, C, D] = andThen(Getter_[A, B, C, D](f)) - /** compose this [[Traversal_]] with an [[Iso_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: Iso_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { + /** compose this [[Traversal_]] with an [[Iso_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: Iso_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Wander[P]): P[S, T] = self(other(pab)) } - /** compose this [[Traversal_]] with an [[Iso_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: Iso_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { + /** compose this [[Traversal_]] with an [[Iso_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: Iso_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Wander[P]): P[C, D] = other(self(pab)) } - /** compose this [[Traversal_]] with an [[AnIso_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: AnIso_[A, B, C, D]): Traversal_[S, T, C, D] = + /** compose this [[Traversal_]] with an [[AnIso_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: AnIso_[A, B, C, D]): Traversal_[S, T, C, D] = wander(new LensLike[S, T, C, D] { override def apply[F[_]](f: C => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.overF(f)) }) - /** compose this [[Traversal_]] with an [[AnIso_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: AnIso_[C, D, S, T]): Traversal_[C, D, A, B] = + /** compose this [[Traversal_]] with an [[AnIso_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: AnIso_[C, D, S, T]): Traversal_[C, D, A, B] = wander(new LensLike[C, D, A, B] { override def apply[F[_]](f: A => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF(f)) }) - /** compose this [[Traversal_]] with a [[Lens_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: Lens_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { + /** compose this [[Traversal_]] with a [[Lens_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: Lens_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev: Wander[P]): P[S, T] = self(other(pab)) } - /** compose this [[Traversal_]] with a [[Lens_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: Lens_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { + /** compose this [[Traversal_]] with a [[Lens_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: Lens_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Wander[P]): P[C, D] = other(self(pab)) } - /** compose this [[Traversal_]] with an [[ALens_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: ALens_[A, B, C, D]): Traversal_[S, T, C, D] = + /** compose this [[Traversal_]] with an [[ALens_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: ALens_[A, B, C, D]): Traversal_[S, T, C, D] = wander(new LensLike[S, T, C, D] { override def apply[F[_]](f: C => F[D])(implicit ev: Applicative[F]): S => F[T] = self.traverse(_)(other.traverse(_)(f)) }) - /** compose this [[Traversal_]] with an [[ALens_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: ALens_[C, D, S, T]): Traversal_[C, D, A, B] = + /** compose this [[Traversal_]] with an [[ALens_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: ALens_[C, D, S, T]): Traversal_[C, D, A, B] = wander(new LensLike[C, D, A, B] { override def apply[F[_]](f: A => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF(f)) }) - /** compose this [[Traversal_]] with a [[Prism_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: Prism_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { + /** compose this [[Traversal_]] with a [[Prism_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: Prism_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { override private[proptics] def apply[P[_, _]](pab: P[C, D])(implicit ev: Wander[P]): P[S, T] = self(other(pab)) } - /** compose this [[Traversal_]] with a [[Prism_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: Prism_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { + /** compose this [[Traversal_]] with a [[Prism_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: Prism_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Wander[P]): P[C, D] = other(self(pab)) } - /** compose this [[Traversal_]] with an [[APrism_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: APrism_[A, B, C, D]): Traversal_[S, T, C, D] = + /** compose this [[Traversal_]] with an [[APrism_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: APrism_[A, B, C, D]): Traversal_[S, T, C, D] = wander(new LensLike[S, T, C, D] { override def apply[F[_]](f: C => F[D])(implicit ev: Applicative[F]): S => F[T] = self.traverse(_)(other.traverse(_)(f)) }) - /** compose this [[Traversal_]] with an [[APrism_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: APrism_[C, D, S, T]): Traversal_[C, D, A, B] = + /** compose this [[Traversal_]] with an [[APrism_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: APrism_[C, D, S, T]): Traversal_[C, D, A, B] = wander(new LensLike[C, D, A, B] { override def apply[F[_]](f: A => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF(f)) }) - /** compose this [[Traversal_]] with an [[AffineTraversal_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: AffineTraversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { + /** compose this [[Traversal_]] with an [[AffineTraversal_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: AffineTraversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Wander[P]): P[S, T] = self(other(pab)) } - /** compose this [[Traversal_]] with an [[AffineTraversal_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: AffineTraversal_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { + /** compose this [[Traversal_]] with an [[AffineTraversal_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: AffineTraversal_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Wander[P]): P[C, D] = other(self(pab)) } - /** compose this [[Traversal_]] with an [[AnAffineTraversal_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: AnAffineTraversal_[A, B, C, D]): Traversal_[S, T, C, D] = + /** compose this [[Traversal_]] with an [[AnAffineTraversal_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: AnAffineTraversal_[A, B, C, D]): Traversal_[S, T, C, D] = wander(new LensLike[S, T, C, D] { override def apply[F[_]](f: C => F[D])(implicit ev: Applicative[F]): S => F[T] = self.overF(other.traverse(_)(f)) }) - /** compose this [[Traversal_]] with an [[AnAffineTraversal_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: AnAffineTraversal_[C, D, S, T]): Traversal_[C, D, A, B] = + /** compose this [[Traversal_]] with an [[AnAffineTraversal_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: AnAffineTraversal_[C, D, S, T]): Traversal_[C, D, A, B] = wander(new LensLike[C, D, A, B] { override def apply[F[_]](f: A => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF(self.overF(f)) }) - /** compose this [[Traversal_]] with a [[Traversal_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { + /** compose this [[Traversal_]] with a [[Traversal_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: Traversal_[A, B, C, D]): Traversal_[S, T, C, D] = new Traversal_[S, T, C, D] { override def apply[P[_, _]](pab: P[C, D])(implicit ev: Wander[P]): P[S, T] = self(other(pab)) } - /** compose this [[Traversal_]] with a [[Traversal_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { + /** compose this [[Traversal_]] with a [[Traversal_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: Traversal_[C, D, S, T]): Traversal_[C, D, A, B] = new Traversal_[C, D, A, B] { override private[proptics] def apply[P[_, _]](pab: P[A, B])(implicit ev: Wander[P]): P[C, D] = other(self(pab)) } - /** compose this [[Traversal_]] with an [[ATraversal_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = + /** compose this [[Traversal_]] with an [[ATraversal_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: ATraversal_[A, B, C, D]): ATraversal_[S, T, C, D] = ATraversal_(new RunBazaar[* => *, C, D, S, T] { override def apply[F[_]](pafb: C => F[D])(s: S)(implicit ev: Applicative[F]): F[T] = self.traverse(s)(other.traverse(_)(pafb)) }) - /** compose this [[Traversal_]] with an [[ATraversal_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = + /** compose this [[Traversal_]] with an [[ATraversal_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: ATraversal_[C, D, S, T]): ATraversal_[C, D, A, B] = ATraversal_(new RunBazaar[* => *, A, B, C, D] { override def apply[F[_]](pafb: A => F[B])(c: C)(implicit ev: Applicative[F]): F[D] = other.traverse(c)(self.overF(pafb)) }) - /** compose this [[Traversal_]] with a [[Setter_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { + /** compose this [[Traversal_]] with a [[Setter_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: Setter_[A, B, C, D]): Setter_[S, T, C, D] = new Setter_[S, T, C, D] { override private[proptics] def apply(pab: C => D): S => T = self(other(pab)) } - /** compose this [[Traversal_]] with a [[Setter_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { + /** compose this [[Traversal_]] with a [[Setter_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: Setter_[C, D, S, T]): Setter_[C, D, A, B] = new Setter_[C, D, A, B] { override private[proptics] def apply(pab: A => B): C => D = other(self(pab)) } - /** compose this [[Traversal_]] with a [[Getter_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Traversal_]] with a [[Getter_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: Getter_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(forget.runForget compose other.view)) } - /** compose this [[Traversal_]] with a [[Getter_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Traversal_]] with a [[Getter_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: Getter_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = Forget(c => self.foldMap(other.view(c))(forget.runForget)) } - /** compose this [[Traversal_]] with a [[Fold_]], having this [[Traversal_]] applied last */ - final def compose[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { + /** compose this [[Traversal_]] with a [[Fold_]], having this [[Traversal_]] applied first */ + final def andThen[C, D](other: Fold_[A, B, C, D]): Fold_[S, T, C, D] = new Fold_[S, T, C, D] { override def apply[R: Monoid](forget: Forget[R, C, D]): Forget[R, S, T] = self(other(forget)) } - /** compose this [[Traversal_]] with a [[Fold_]], having this [[Traversal_]] applied first */ - final def andThen[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { + /** compose this [[Traversal_]] with a [[Fold_]], having this [[Traversal_]] applied last */ + final def compose[C, D](other: Fold_[C, D, S, T]): Fold_[C, D, A, B] = new Fold_[C, D, A, B] { override private[proptics] def apply[R: Monoid](forget: Forget[R, A, B]): Forget[R, C, D] = other(self(forget)) } - /** compose this [[Traversal_]] with an [[IndexedLens_]], having this [[Traversal_]] applied last */ - final def compose[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[Traversal_]] with an [[IndexedLens_]], having this [[Traversal_]] applied first */ + final def andThen[I, C, D](other: IndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.traverse(_)(other.traverse(_)(f)) }) - /** compose this [[Traversal_]] with an [[IndexedLens_]], having this [[Traversal_]] applied first */ - final def andThen[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[Traversal_]] with an [[IndexedLens_]], having this [[Traversal_]] applied last */ + final def compose[I, C, D](other: IndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[Traversal_]] with an [[AnIndexedLens_]], having this [[Traversal_]] applied last */ - final def compose[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[Traversal_]] with an [[AnIndexedLens_]], having this [[Traversal_]] applied first */ + final def andThen[I, C, D](other: AnIndexedLens_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.traverse(_)(other.traverse(_)(f)) }) - /** compose this [[Traversal_]] with an [[AnIndexedLens_]], having this [[Traversal_]] applied first */ - final def andThen[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[Traversal_]] with an [[AnIndexedLens_]], having this [[Traversal_]] applied last */ + final def compose[I, C, D](other: AnIndexedLens_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[Traversal_]] with an [[IndexedTraversal_]], having this [[Traversal_]] applied last */ - final def compose[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = + /** compose this [[Traversal_]] with an [[IndexedTraversal_]], having this [[Traversal_]] applied first */ + final def andThen[I, C, D](other: IndexedTraversal_[I, A, B, C, D]): IndexedTraversal_[I, S, T, C, D] = IndexedTraversal_.wander(new LensLikeWithIndex[I, S, T, C, D] { override def apply[F[_]](f: ((C, I)) => F[D])(implicit ev: Applicative[F]): S => F[T] = self.traverse(_)(other.traverse(_)(f)) }) - /** compose this [[Traversal_]] with an [[IndexedTraversal_]], having this [[Traversal_]] applied first */ - final def andThen[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = + /** compose this [[Traversal_]] with an [[IndexedTraversal_]], having this [[Traversal_]] applied last */ + final def compose[I, C, D](other: IndexedTraversal_[I, C, D, S, T]): IndexedTraversal_[I, C, D, A, B] = IndexedTraversal_.wander(new LensLikeWithIndex[I, C, D, A, B] { override def apply[F[_]](f: ((A, I)) => F[B])(implicit ev: Applicative[F]): C => F[D] = other.overF { case (s, i) => self.traverse(s)(a => f((a, i))) } }) - /** compose this [[Traversal_]] with an [[IndexedSetter_]], having this [[Traversal_]] applied last */ - final def compose[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { + /** compose this [[Traversal_]] with an [[IndexedSetter_]], having this [[Traversal_]] applied first */ + final def andThen[I, C, D](other: IndexedSetter_[I, A, B, C, D]): IndexedSetter_[I, S, T, C, D] = new IndexedSetter_[I, S, T, C, D] { override private[proptics] def apply(indexed: Indexed[* => *, I, C, D]): S => T = self.over(other.over(indexed.runIndex)) } - /** compose this [[Traversal_]] with an [[IndexedSetter_]], having this [[Traversal_]] applied first */ - final def andThen[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { + /** compose this [[Traversal_]] with an [[IndexedSetter_]], having this [[Traversal_]] applied last */ + final def compose[I, C, D](other: IndexedSetter_[I, C, D, S, T]): IndexedSetter_[I, C, D, A, B] = new IndexedSetter_[I, C, D, A, B] { override private[proptics] def apply(indexed: Indexed[Function, I, A, B]): C => D = other.over { case (s, i) => self.over(a => indexed.runIndex((a, i)))(s) } } - /** compose this [[Traversal_]] with an [[IndexedGetter_]], having this [[Traversal_]] applied last */ - final def compose[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Traversal_]] with an [[IndexedGetter_]], having this [[Traversal_]] applied first */ + final def andThen[I, C, D](other: IndexedGetter_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(indexed.runIndex.runForget compose other.view)) } - /** compose this [[Traversal_]] with an [[IndexedGetter_]], having this [[Traversal_]] applied first */ - final def andThen[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Traversal_]] with an [[IndexedGetter_]], having this [[Traversal_]] applied last */ + final def compose[I, C, D](other: IndexedGetter_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget { c => val (s, i) = other.view(c) @@ -410,14 +410,14 @@ abstract class Traversal_[S, T, A, B] extends Serializable { self => } } - /** compose this [[Traversal_]] with an [[IndexedFold_]], having this [[Traversal_]] applied last */ - final def compose[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { + /** compose this [[Traversal_]] with an [[IndexedFold_]], having this [[Traversal_]] applied first */ + final def andThen[I, C, D](other: IndexedFold_[I, A, B, C, D]): IndexedFold_[I, S, T, C, D] = new IndexedFold_[I, S, T, C, D] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, C, D]): Forget[R, S, T] = Forget(self.foldMap(_)(other.foldMap(_)(indexed.runIndex.runForget))) } - /** compose this [[Traversal_]] with an [[IndexedFold_]], having this [[Traversal_]] applied first */ - final def andThen[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { + /** compose this [[Traversal_]] with an [[IndexedFold_]], having this [[Traversal_]] applied last */ + final def compose[I, C, D](other: IndexedFold_[I, C, D, S, T]): IndexedFold_[I, C, D, A, B] = new IndexedFold_[I, C, D, A, B] { override private[proptics] def apply[R: Monoid](indexed: Indexed[Forget[R, *, *], I, A, B]): Forget[R, C, D] = Forget(other.foldMap(_) { case (s, i) => self.foldMap(s)(a => indexed.runIndex.runForget((a, i))) }) } diff --git a/core/shared/src/main/scala/proptics/instances/EachInstances.scala b/core/shared/src/main/scala/proptics/instances/EachInstances.scala index 844ff7a84..a8a151ae6 100644 --- a/core/shared/src/main/scala/proptics/instances/EachInstances.scala +++ b/core/shared/src/main/scala/proptics/instances/EachInstances.scala @@ -35,7 +35,7 @@ trait EachInstances extends ScalaVersionSpecificEachInstances { self => implicit final def eachString: Each[String, Char] = new Each[String, Char] { override def each: Traversal[String, Char] = - stringToChars compose self.each[List[Char], Char] + stringToChars andThen self.each[List[Char], Char] } implicit final def eachVector[A]: Each[Vector[A], A] = new Each[Vector[A], A] { diff --git a/core/shared/src/main/scala/proptics/instances/PrefixedInstances.scala b/core/shared/src/main/scala/proptics/instances/PrefixedInstances.scala index e28946d3f..c10561431 100644 --- a/core/shared/src/main/scala/proptics/instances/PrefixedInstances.scala +++ b/core/shared/src/main/scala/proptics/instances/PrefixedInstances.scala @@ -18,8 +18,8 @@ trait PrefixedInstances extends ScalaVersionSpecificPrefixedInstances { self => implicit final def prefixedString: Prefixed[String, String] = new Prefixed[String, String] { override def prefixed(s: String): Prism[String, String] = - stringToChars compose - self.prefixed[List[Char], List[Char]](s.toList) compose + stringToChars andThen + self.prefixed[List[Char], List[Char]](s.toList) andThen charsToString } diff --git a/core/shared/src/main/scala/proptics/instances/SuffixedInstances.scala b/core/shared/src/main/scala/proptics/instances/SuffixedInstances.scala index 96877abd1..b36aa03f7 100644 --- a/core/shared/src/main/scala/proptics/instances/SuffixedInstances.scala +++ b/core/shared/src/main/scala/proptics/instances/SuffixedInstances.scala @@ -23,8 +23,8 @@ trait SuffixedInstances extends ScalaVersionSpecificSuffixedInstances { self => implicit final def suffixedString: Suffixed[String, String] = new Suffixed[String, String] { override def suffixed(s: String): Prism[String, String] = - stringToChars compose - self.suffixed[List[Char], List[Char]](s.toList) compose + stringToChars andThen + self.suffixed[List[Char], List[Char]](s.toList) andThen charsToString } diff --git a/core/shared/src/main/scala/proptics/internal/Exchange.scala b/core/shared/src/main/scala/proptics/internal/Exchange.scala index 5f0fd5ec4..32a132453 100644 --- a/core/shared/src/main/scala/proptics/internal/Exchange.scala +++ b/core/shared/src/main/scala/proptics/internal/Exchange.scala @@ -5,7 +5,7 @@ import cats.arrow.Profunctor /** The [[Exchange]] [[cats.arrow.Profunctor]] characterizes an [[proptics.Iso_]] */ final case class Exchange[A, B, S, T](view: S => A, review: B => T) { self => - def compose[C, D](other: Exchange[C, D, A, B]): Exchange[C, D, S, T] = + def andThen[C, D](other: Exchange[C, D, A, B]): Exchange[C, D, S, T] = Exchange(other.view compose self.view, self.review compose other.review) } diff --git a/core/shared/src/main/scala/proptics/internal/Market.scala b/core/shared/src/main/scala/proptics/internal/Market.scala index 4c06c2579..a86fdce65 100644 --- a/core/shared/src/main/scala/proptics/internal/Market.scala +++ b/core/shared/src/main/scala/proptics/internal/Market.scala @@ -9,7 +9,7 @@ import proptics.profunctor.Choice /** The [[Market]] [[cats.arrow.Profunctor]] characterizes a [[proptics.Prism_]] */ final case class Market[A, B, S, T](viewOrModify: S => Either[T, A], review: B => T) { self => - def compose[C, D](other: Market[C, D, A, B])(implicit ev: FlatMap[Either[T, *]]): Market[C, D, S, T] = { + def andThen[C, D](other: Market[C, D, A, B])(implicit ev: FlatMap[Either[T, *]]): Market[C, D, S, T] = { val kleisli = Kleisli[Either[T, *], A, C](other.viewOrModify(_).leftMap(self.review)) Market((kleisli compose self.viewOrModify).run, self.review compose other.review) diff --git a/core/shared/src/main/scala/proptics/internal/Shop.scala b/core/shared/src/main/scala/proptics/internal/Shop.scala index 04002888e..23e369788 100644 --- a/core/shared/src/main/scala/proptics/internal/Shop.scala +++ b/core/shared/src/main/scala/proptics/internal/Shop.scala @@ -4,7 +4,7 @@ import cats.arrow.{Profunctor, Strong} /** The Shop profunctor characterizes a [[proptics.Lens_]] */ final case class Shop[A, B, S, T](view: S => A, set: S => B => T) { - def compose[C, D](other: Shop[C, D, A, B]): Shop[C, D, S, T] = + def andThen[C, D](other: Shop[C, D, A, B]): Shop[C, D, S, T] = Shop(other.view compose view, s => d => set(s)(other.set(view(s))(d))) } diff --git a/core/shared/src/main/scala/proptics/std/StringOptics.scala b/core/shared/src/main/scala/proptics/std/StringOptics.scala index 89ae4e719..a966e4bfc 100644 --- a/core/shared/src/main/scala/proptics/std/StringOptics.scala +++ b/core/shared/src/main/scala/proptics/std/StringOptics.scala @@ -12,7 +12,7 @@ trait StringOptics { final val stringToChars: Iso[String, List[Char]] = charsToString.reverse /** fold over the individual words of a String */ - val words: Traversal[String, String] = mkString(" ") compose split("\\s+") + val words: Traversal[String, String] = mkString(" ") andThen split("\\s+") /** shows all elements of a collection in a string using a separator string */ def mkString(sep: String): Iso_[String, String, String, List[String]] = diff --git a/core/shared/src/main/scala/proptics/typeclass/At.scala b/core/shared/src/main/scala/proptics/typeclass/At.scala index dbb85bd03..61d080ae7 100644 --- a/core/shared/src/main/scala/proptics/typeclass/At.scala +++ b/core/shared/src/main/scala/proptics/typeclass/At.scala @@ -25,6 +25,6 @@ object At { override def at(i: I): Lens[S, Option[A]] = Lens[S, Option[A]](view(i))(set(i)) override def ix(i: I): AffineTraversal[S, A] = - at(i) compose (some[A] compose AffineTraversal.id[A]) + at(i) andThen (some[A] andThen AffineTraversal.id[A]) } } diff --git a/core/shared/src/main/scala/proptics/typeclass/Cons.scala b/core/shared/src/main/scala/proptics/typeclass/Cons.scala index 1f7adc9c9..8e6c6f6dc 100644 --- a/core/shared/src/main/scala/proptics/typeclass/Cons.scala +++ b/core/shared/src/main/scala/proptics/typeclass/Cons.scala @@ -16,9 +16,9 @@ import proptics.{AffineTraversal, Prism} trait Cons[S, A] extends Serializable { def cons: Prism[S, (A, S)] - def headOption: AffineTraversal[S, A] = cons compose _1[A, S] + def headOption: AffineTraversal[S, A] = cons andThen _1[A, S] - def tailOption: AffineTraversal[S, S] = cons compose _2[A, S] + def tailOption: AffineTraversal[S, S] = cons andThen _2[A, S] } object Cons { diff --git a/core/shared/src/main/scala/proptics/typeclass/NonEmptyCons.scala b/core/shared/src/main/scala/proptics/typeclass/NonEmptyCons.scala index 7861e3371..dd4a60aab 100644 --- a/core/shared/src/main/scala/proptics/typeclass/NonEmptyCons.scala +++ b/core/shared/src/main/scala/proptics/typeclass/NonEmptyCons.scala @@ -19,9 +19,9 @@ import proptics.{Iso, Lens} trait NonEmptyCons[S, H, T] extends Serializable { def nonEmptyCons: Iso[S, (H, T)] - def head: Lens[S, H] = nonEmptyCons compose _1[H, T] + def head: Lens[S, H] = nonEmptyCons andThen _1[H, T] - def tail: Lens[S, T] = nonEmptyCons compose _2[H, T] + def tail: Lens[S, T] = nonEmptyCons andThen _2[H, T] } object NonEmptyCons { diff --git a/docs/src/main/mdoc/an-optics/a-lens.md b/docs/src/main/mdoc/an-optics/a-lens.md index 9edb90987..aa911bd9b 100644 --- a/docs/src/main/mdoc/an-optics/a-lens.md +++ b/docs/src/main/mdoc/an-optics/a-lens.md @@ -186,7 +186,7 @@ val passwordLens = ALens[AccountSecurity, String](_.password) { security => pass } // passwordLens: proptics.ALens[AccountSecurity,String] = proptics.ALens_$$anon$11@73c60f21 -val userPasswordLens = accountSecurityLens compose passwordLens +val userPasswordLens = accountSecurityLens andThen passwordLens // userPasswordLens: proptics.ALens[User,String] = proptics.ALens_$$anon$2@27ae8f48 userPasswordLens.view(user) @@ -202,7 +202,7 @@ userPasswordLens.over(_.reverse)(user) We can also use an inline composition ```scala -(accountSecurityLens compose passwordLens).over(_.reverse)(user) +(accountSecurityLens andThen passwordLens).over(_.reverse)(user) // res3: User = User(user99,user@email.com,AccountSecurity(!654321,true)) ``` diff --git a/docs/src/main/mdoc/optics/lens.md b/docs/src/main/mdoc/optics/lens.md index e4a8711fc..54ab22289 100644 --- a/docs/src/main/mdoc/optics/lens.md +++ b/docs/src/main/mdoc/optics/lens.md @@ -183,7 +183,7 @@ val passwordLens = Lens[AccountSecurity, String](_.password) { security => passw } // passwordLens: proptics.Lens[AccountSecurity,String] = proptics.Lens_$$anon$11@73c60f21 -val userPasswordLens = accountSecurityLens compose passwordLens +val userPasswordLens = accountSecurityLens andThen passwordLens // userPasswordLens: proptics.Lens[User,String] = proptics.Lens_$$anon$2@27ae8f48 userPasswordLens.view(user) @@ -199,7 +199,7 @@ userPasswordLens.over(_.reverse)(user) We can also use an inline composition ```scala -(accountSecurityLens compose passwordLens).over(_.reverse)(user) +(accountSecurityLens andThen passwordLens).over(_.reverse)(user) // res3: User = User(user99,user@email.com,AccountSecurity(!654321,true)) ``` diff --git a/docs/src/main/mdoc/overview.md b/docs/src/main/mdoc/overview.md index c7997f891..40cf7b2b7 100644 --- a/docs/src/main/mdoc/overview.md +++ b/docs/src/main/mdoc/overview.md @@ -19,8 +19,8 @@ To get started with [sbt](https://scala-sbt.org), simply add the following line ```scala libraryDependencies ++= Seq( - "@ORGANIZATION@" %% "@CORE_MODULE_NAME@" % "0.3.0", - "@ORGANIZATION@" %% "proptics-profunctor" % "0.3.0" + "@ORGANIZATION@" %% "@CORE_MODULE_NAME@" % "0.3.1", + "@ORGANIZATION@" %% "proptics-profunctor" % "0.3.1" ) ``` diff --git a/docs/src/main/mdoc/quick-example.md b/docs/src/main/mdoc/quick-example.md index 659625c45..c118b3feb 100644 --- a/docs/src/main/mdoc/quick-example.md +++ b/docs/src/main/mdoc/quick-example.md @@ -27,7 +27,7 @@ import proptics.instances.tuple._ val tupled: (((String, Int), Int), Int) = ((("hi!", 3), 2), 1) // tupled: (((String, Int), Int), Int) = (((hi!,3),2),1) -val leftmost = _1[((String, Int), Int), Int] compose _1[(String, Int), Int] compose _1[String, Int] +val leftmost = _1[((String, Int), Int), Int] andThen _1[(String, Int), Int] andThen _1[String, Int] // leftmost: proptics.Lens[(((String, Int), Int), Int),String] = proptics.Lens_$$anon$2@716c8dae leftmost.view(((("hi!", 3), 2), 1)) @@ -59,7 +59,7 @@ object Main extends IOApp { } yield ExitCode.Success val leftmost: Lens[(((String, Int), Int), Int), String] = - _1[((String, Int), Int), Int] compose _1[(String, Int), Int] compose _1[String, Int] + _1[((String, Int), Int), Int] andThen _1[(String, Int), Int] andThen _1[String, Int] def putStrLn[A: Show](x: A): IO[Unit] = IO(println(x.show)) } diff --git a/example/src/test/scala/optics/AffineTraversalExamples.scala b/example/src/test/scala/optics/AffineTraversalExamples.scala index 94d5af641..c49f247aa 100644 --- a/example/src/test/scala/optics/AffineTraversalExamples.scala +++ b/example/src/test/scala/optics/AffineTraversalExamples.scala @@ -13,14 +13,14 @@ import proptics.{AffineTraversal, Traversal} class AffineTraversalExamples extends PropticsSuite { test("preview the head of a list within a tuple") { - val composed = _2[Int, List[String]] compose headOption[List[String], String] + val composed = _2[Int, List[String]] andThen headOption[List[String], String] val result = composed.preview((9, List("head", "?", "?"))) assertResult("head".some)(result) } test("transform each head of a nested list to upper case") { - val composed = Traversal.fromTraverse[List, List[String]] compose headOption[List[String], String] + val composed = Traversal.fromTraverse[List, List[String]] andThen headOption[List[String], String] val result = composed.over(_.toUpperCase)(List(List("a", "b", "c"), List("b", "c", "d"), List.empty)) assertResult(List(List("A", "b", "c"), List("B", "c", "d"), List.empty))(result) @@ -28,9 +28,9 @@ class AffineTraversalExamples extends PropticsSuite { test("remove the suffix or prefix of a string") { val suffixedComposed: AffineTraversal[(String, Int), String] = - _1[String, Int] compose suffixed[String, String]("fixed") + _1[String, Int] andThen suffixed[String, String]("fixed") val prefixedComposed: AffineTraversal[(String, Int), String] = - _1[String, Int] compose prefixed[String, String]("pre") + _1[String, Int] andThen prefixed[String, String]("pre") assertResult("suf".some)(suffixedComposed.preview(("suffixed", 9))) assertResult("pre".some)(suffixedComposed.preview(("prefixed", 9))) diff --git a/example/src/test/scala/optics/FoldExamples.scala b/example/src/test/scala/optics/FoldExamples.scala index 4099c98f4..5f99b55ae 100644 --- a/example/src/test/scala/optics/FoldExamples.scala +++ b/example/src/test/scala/optics/FoldExamples.scala @@ -42,16 +42,16 @@ class FoldExamples extends PropticsSuite { // implicit cast from [[Lens_]] to [[Fold_]] val designer: Fold[Language, String] = Lens[Language, String](_.designer)(lang => designer => lang.copy(designer = designer)) - val composed: Fold[List[Language], String] = Fold.fromFoldable[List, Language] compose designer + val composed: Fold[List[Language], String] = Fold.fromFoldable[List, Language] andThen designer assertResult(languages.map(_.designer))(composed.viewAll(languages)) } test("compose folds") { val composed = - Fold.fromFoldable[List, (Int, String)] compose - Fold.fromFoldable[(Int, *), String] compose - stringToChars compose + Fold.fromFoldable[List, (Int, String)] andThen + Fold.fromFoldable[(Int, *), String] andThen + stringToChars andThen Fold.fromFoldable[List, Char] val input = List((0, "Govan"), (1, "Abassi"), (2, "Gambale")) @@ -71,7 +71,7 @@ class FoldExamples extends PropticsSuite { test("sum all number of episodes") { val numberOfEpisodes = - Fold.fromFoldable[List, TVShow] compose + Fold.fromFoldable[List, TVShow] andThen Fold[TVShow, Int](_.numEpisodes) assertResult(125)(numberOfEpisodes.sum(tvShows)) @@ -79,7 +79,7 @@ class FoldExamples extends PropticsSuite { test("get the maximum score of all tv shows") { val maxScore = - Fold.fromFoldable[List, TVShow] compose + Fold.fromFoldable[List, TVShow] andThen Fold[TVShow, Int](_.criticScore) assertResult(97.some)(maxScore.maximum(tvShows)) @@ -94,15 +94,15 @@ class FoldExamples extends PropticsSuite { test("get the name of the oldest actor") { implicit val actorsOrder: Order[Actor] = Order.by(_.birthYear) - val actors = Fold.fromFoldable[List, TVShow] compose - Fold[TVShow, List[Actor]](_.actors) compose + val actors = Fold.fromFoldable[List, TVShow] andThen + Fold[TVShow, List[Actor]](_.actors) andThen Fold.fromFoldable[List, Actor] assertResult("Jonathan Banks".some)(actors.minimum(tvShows).map(_.name)) } test("actors who participate in more than one show") { - val actors = Fold.fromFoldable[List, TVShow] compose + val actors = Fold.fromFoldable[List, TVShow] andThen Fold[TVShow, Map[String, Int]](_.actors.map(_.name -> 1).toMap) val expected = List("Jonathan Banks", "Giancarlo Esposito", "Bob Odenkirk") toSet @@ -114,9 +114,9 @@ class FoldExamples extends PropticsSuite { test("View all actors that their first name starts with the letter 'A'") { val fold = - Fold.fromFoldable[List, TVShow] to (_.actors) compose - Fold.fromFoldable[List, Actor] to [String, String] (_.name) compose - Fold.filter[String](_.startsWith("A")) compose + Fold.fromFoldable[List, TVShow] to (_.actors) andThen + Fold.fromFoldable[List, Actor] to [String, String] (_.name) andThen + Fold.filter[String](_.startsWith("A")) andThen words.take(1) assertResult(List("Aaron", "Anna"))(fold.viewAll(tvShows)) @@ -124,12 +124,12 @@ class FoldExamples extends PropticsSuite { test("using fold as a predicate, count the number of awards of all actors that were nominated for golden globe but did not win") { implicit val eqActor: Eq[Award] = Eq.fromUniversalEquals[Award] - val foldPredicate = Getter[Actor, Award](_.nomiation) compose Prism.only[Award](GoldenGlobe) + val foldPredicate = Getter[Actor, Award](_.nomiation) andThen Prism.only[Award](GoldenGlobe) val fold = - Getter[TVShow, List[Actor]](_.actors) compose - Fold.fromFoldable[List, Actor] compose - Fold.filter(foldPredicate) compose - Getter[Actor, List[Award]](_.awards) compose + Getter[TVShow, List[Actor]](_.actors) andThen + Fold.fromFoldable[List, Actor] andThen + Fold.filter(foldPredicate) andThen + Getter[Actor, List[Award]](_.awards) andThen Fold.filter[List[Award]](!_.contains(GoldenGlobe)) assertResult(5)(fold.foldMap(breakingBad)(_.length)) @@ -137,11 +137,11 @@ class FoldExamples extends PropticsSuite { test("are there any actors born before 1970 and don't have any nominations") { implicit val eqActor: Eq[Award] = Eq.fromUniversalEquals[Award] - val foldPredicate = Getter[Actor, Award](_.nomiation) compose Prism.only[Award](None_) + val foldPredicate = Getter[Actor, Award](_.nomiation) andThen Prism.only[Award](None_) val fold = - Fold.fromFoldable[List, TVShow] compose - Getter[TVShow, List[Actor]](_.actors) compose - Fold.fromFoldable[List, Actor] compose + Fold.fromFoldable[List, TVShow] andThen + Getter[TVShow, List[Actor]](_.actors) andThen + Fold.fromFoldable[List, Actor] andThen Fold.filter(foldPredicate) assertResult(true)(fold.any(tvShows)(_.birthYear < 1970)) @@ -156,7 +156,7 @@ class FoldExamples extends PropticsSuite { test("select the first word from each sentence in a list") { val fold = - Fold.fromFoldable[List, String] compose + Fold.fromFoldable[List, String] andThen words.take(1) val input = List("Say Anything", "My Octopus Teacher", "Name of the Rose") diff --git a/example/src/test/scala/optics/GetterExamples.scala b/example/src/test/scala/optics/GetterExamples.scala index 92f3b6887..f5ca5e5a7 100644 --- a/example/src/test/scala/optics/GetterExamples.scala +++ b/example/src/test/scala/optics/GetterExamples.scala @@ -6,7 +6,7 @@ import proptics.specs.PropticsSuite class GetterExamples extends PropticsSuite { test("focus into nested data") { val composed = - Getter[Person, Address](_.address) compose + Getter[Person, Address](_.address) andThen Getter[Address, Street](_.street) assertResult(Street("Negra Arroyo Lane", 308))(composed.view(mrWhite)) diff --git a/example/src/test/scala/optics/IndexedFoldExamples.scala b/example/src/test/scala/optics/IndexedFoldExamples.scala index b1de63f60..e2acf04a4 100644 --- a/example/src/test/scala/optics/IndexedFoldExamples.scala +++ b/example/src/test/scala/optics/IndexedFoldExamples.scala @@ -109,7 +109,7 @@ class IndexedFoldExamples extends PropticsSuite { test("compose with non indexed optic") { val map = Map("Scala" -> (("Some", "None")), "Haskell" -> (("Just", "Nothing"))) val mapFold = - IndexedFold.fromFoldableWithIndex[Map[String, *], String, (String, String)] compose + IndexedFold.fromFoldableWithIndex[Map[String, *], String, (String, String)] andThen _1[String, String] val expected = List(("Some", "Scala"), ("Just", "Haskell")) @@ -121,7 +121,7 @@ class IndexedFoldExamples extends PropticsSuite { val tupledMaps = (Map("a" -> 1, "b" -> 2), Map("c" -> 3, "d" -> 4)) val indexedTraversal: IndexedFold[String, Map[String, Int], Int] = IndexedFold.fromFoldableWithIndex[Map[String, *], String, Int] - val mapTraversal = both[(*, *), Map[String, Int]] compose indexedTraversal + val mapTraversal = both[(*, *), Map[String, Int]] andThen indexedTraversal val expected = List((1, "a"), (2, "b"), (3, "c"), (4, "d")) assertResult(expected)(mapTraversal.viewAll(tupledMaps)) @@ -139,7 +139,7 @@ class IndexedFoldExamples extends PropticsSuite { test("list out the number of commits for each day for a specific repo in the past week") { val expected = List((10, "Sunday"), (15, "Monday"), (5, "Wednesday"), (3, "Friday")) val traversal = - IndexedFold.fromFoldableWithIndex[Map[String, *], String, Map[String, Int]] compose + IndexedFold.fromFoldableWithIndex[Map[String, *], String, Map[String, Int]] andThen index[Map[String, Int], String, Int]("repo A") assertResult(expected)(traversal.viewAll(commits)) diff --git a/example/src/test/scala/optics/IndexedTraversalExamples.scala b/example/src/test/scala/optics/IndexedTraversalExamples.scala index 992a0c9f5..5eed005fb 100644 --- a/example/src/test/scala/optics/IndexedTraversalExamples.scala +++ b/example/src/test/scala/optics/IndexedTraversalExamples.scala @@ -104,7 +104,7 @@ class tIndexedTraversalExamples extends PropticsSuite { test("compose with non indexed optic") { val map = Map("Scala" -> (("Some", "None")), "Haskell" -> (("Just", "Nothing"))) val mapTraversal = - IndexedTraversal.fromTraverseWithIndex[Map[String, *], String, (String, String)] compose + IndexedTraversal.fromTraverseWithIndex[Map[String, *], String, (String, String)] andThen _1[String, String] val expected = List(("Some", "Scala"), ("Just", "Haskell")) @@ -116,7 +116,7 @@ class tIndexedTraversalExamples extends PropticsSuite { val tupledMaps = (Map("a" -> 1, "b" -> 2), Map("c" -> 3, "d" -> 4)) val indexedTraversal: IndexedTraversal[String, Map[String, Int], Int] = IndexedTraversal.fromTraverseWithIndex[Map[String, *], String, Int] - val mapTraversal = both[(*, *), Map[String, Int]] compose indexedTraversal + val mapTraversal = both[(*, *), Map[String, Int]] andThen indexedTraversal val expected = List((1, "a"), (2, "b"), (3, "c"), (4, "d")) assertResult(expected)(mapTraversal.viewAll(tupledMaps)) @@ -134,7 +134,7 @@ class tIndexedTraversalExamples extends PropticsSuite { test("list out the number of commits for each day for a specific repo in the past week") { val expected = List((10, "Sunday"), (15, "Monday"), (5, "Wednesday"), (3, "Friday")) val traversal = - IndexedTraversal.fromTraverseWithIndex[Map[String, *], String, Map[String, Int]] compose + IndexedTraversal.fromTraverseWithIndex[Map[String, *], String, Map[String, Int]] andThen index[Map[String, Int], String, Int]("repo A") assertResult(expected)(traversal.viewAll(commits)) diff --git a/example/src/test/scala/optics/IsoExamples.scala b/example/src/test/scala/optics/IsoExamples.scala index 63529c779..7c4c204b5 100644 --- a/example/src/test/scala/optics/IsoExamples.scala +++ b/example/src/test/scala/optics/IsoExamples.scala @@ -30,16 +30,16 @@ class IsoExamples extends PropticsSuite { test("swap Either twice") { val either: Either[String, Int] = "Hello".asLeft[Int] val swapTwice: Iso[Either[String, Int], Either[String, Int]] = - swapEither compose swapEither + swapEither andThen swapEither assertResult(either)(swapTwice.view(either)) } test("replace the case of all characters using involuted") { val composed = - _2[Int, String] compose - stringToChars compose - involuted[List[Char]](_.map(c => if (c.isUpper) c.toLower else c.toUpper)) compose + _2[Int, String] andThen + stringToChars andThen + involuted[List[Char]](_.map(c => if (c.isUpper) c.toLower else c.toUpper)) andThen charsToString val input = (9, "Hi") @@ -48,8 +48,8 @@ class IsoExamples extends PropticsSuite { test("reverse the string of an either using map") { val composed = - stringToChars compose - reverse[List[Char], List[Char]] compose + stringToChars andThen + reverse[List[Char], List[Char]] andThen charsToString val input = Right("desrever") @@ -59,8 +59,8 @@ class IsoExamples extends PropticsSuite { test("reverse both sides of an either using bimap") { val composed = - stringToChars compose - reverse[List[Char], List[Char]] compose + stringToChars andThen + reverse[List[Char], List[Char]] andThen charsToString assertResult(Right("reversed"))(composed.bimap[Either] view Right("desrever")) diff --git a/example/src/test/scala/optics/LensExamples.scala b/example/src/test/scala/optics/LensExamples.scala index ccc79a785..b7a10fdf6 100644 --- a/example/src/test/scala/optics/LensExamples.scala +++ b/example/src/test/scala/optics/LensExamples.scala @@ -19,7 +19,7 @@ class LensExamples extends PropticsSuite { val streetNumber: Lens[Street, Int] = Lens[Street, Int](_.number)(street => number => street.copy(number = number)) - val personStreet: Lens[Person, Int] = address compose street compose streetNumber + val personStreet: Lens[Person, Int] = address andThen street andThen streetNumber test("pull an effect outside the structure") { val polymorphicFst = _1P[Option[String], String, String] @@ -33,8 +33,8 @@ class LensExamples extends PropticsSuite { test("apply the _1 Lens three times in order to reach the leftmost element") { val leftmost = - _1[((String, Int), Int), Int] compose - _1[(String, Int), Int] compose + _1[((String, Int), Int), Int] andThen + _1[(String, Int), Int] andThen _1[String, Int] val tupled: (((String, Int), Int), Int) = ((("Hi!", 3), 2), 1) @@ -52,8 +52,15 @@ class LensExamples extends PropticsSuite { assertResult(("User99", 2000))(lens.view(UserRegistration("User99", "Password!", 2000))) } - test("deeply nested record") { - val composed = address compose street compose streetNumber + test("deeply nested record using compose") { + val composed = streetNumber compose street compose address + val person = Person("Walter White", Address("Albuquerque", Street("Negra Arroyo Lane", 9))) + + assertResult(mrWhite)(composed.set(308)(person)) + } + + test("deeply nested record using andThen") { + val composed = address andThen street andThen streetNumber val person = Person("Walter White", Address("Albuquerque", Street("Negra Arroyo Lane", 9))) assertResult(mrWhite)(composed.set(308)(person)) @@ -61,7 +68,7 @@ class LensExamples extends PropticsSuite { test("using lenses in order to extract nested data within data structures") { val composed = - _2[String, (List[Int], String)] compose + _2[String, (List[Int], String)] andThen _1[List[Int], String] val list = List(("A", (List(1, 2, 3), "targets")), ("B", (List(4, 5), "targets"))) @@ -74,7 +81,7 @@ class LensExamples extends PropticsSuite { val person = Person("Walter White", Address("Albuquerque", Street("Negra Arroyo Lane", 9))) val expected = Person("Skyler White", Address("Albuquerque", Street("Negra Arroyo Lane", 308))) - val composed = address compose street compose streetNumber + val composed = address andThen street andThen streetNumber val res = person & personNameLens.over(_.replace("Walter", "Skyler")) & composed.set(308) diff --git a/example/src/test/scala/optics/PartsOfExamples.scala b/example/src/test/scala/optics/PartsOfExamples.scala index a72c50ecb..ab195b12d 100644 --- a/example/src/test/scala/optics/PartsOfExamples.scala +++ b/example/src/test/scala/optics/PartsOfExamples.scala @@ -10,10 +10,10 @@ import proptics.syntax.traversal._ import proptics.{ATraversal, Lens, Traversal} class PartsOfExamples extends PropticsSuite { - val traversedTuple1: Traversal[List[(String, Int)], String] = Traversal.fromTraverse[List, (String, Int)] compose _1[String, Int] - val aTraversedTuple1: ATraversal[List[(String, Int)], String] = ATraversal.fromTraverse[List, (String, Int)] compose _1[String, Int] - val traversedTuple2: Traversal[List[(String, Double)], Double] = Traversal.fromTraverse[List, (String, Double)] compose _2[String, Double] - val aTraversedTuple2: ATraversal[List[(String, Double)], Double] = ATraversal.fromTraverse[List, (String, Double)] compose _2[String, Double] + val traversedTuple1: Traversal[List[(String, Int)], String] = Traversal.fromTraverse[List, (String, Int)] andThen _1[String, Int] + val aTraversedTuple1: ATraversal[List[(String, Int)], String] = ATraversal.fromTraverse[List, (String, Int)] andThen _1[String, Int] + val traversedTuple2: Traversal[List[(String, Double)], Double] = Traversal.fromTraverse[List, (String, Double)] andThen _2[String, Double] + val aTraversedTuple2: ATraversal[List[(String, Double)], Double] = ATraversal.fromTraverse[List, (String, Double)] andThen _2[String, Double] val partsOfFromTraversal1: Lens[List[(String, Int)], List[String]] = traversedTuple1.partsOf val partsOfFromATraversal1: Lens[List[(String, Int)], List[String]] = aTraversedTuple1.partsOf val partsOfFromTraversal2: Lens[List[(String, Double)], List[Double]] = traversedTuple2.partsOf diff --git a/example/src/test/scala/optics/PrismExamples.scala b/example/src/test/scala/optics/PrismExamples.scala index 503bdfced..a750b7193 100644 --- a/example/src/test/scala/optics/PrismExamples.scala +++ b/example/src/test/scala/optics/PrismExamples.scala @@ -49,7 +49,7 @@ class PrismExamples extends PropticsSuite { } val serveRequest: Request => String = const("404 Not Found") - val startsWith: String => AffineTraversal[Request, Unit] = path compose headOption[List[String], String] compose Prism.only[String](_) + val startsWith: String => AffineTraversal[Request, Unit] = path andThen headOption[List[String], String] andThen Prism.only[String](_) val pathPrefix: String => Prism[Request, Request] = prefix => Prism.fromPartial[Request, Request] { case req: Request if startsWith(prefix).nonEmpty(req) => path.over(_.drop(1))(req) @@ -68,7 +68,7 @@ class PrismExamples extends PropticsSuite { } test("representation of HTTP web requests as a sum type") { - val traversal = post compose _1[Path, Body] + val traversal = post andThen _1[Path, Body] val expected = POST(List("users", "12345"), "name: John") assertResult(List("users").some)(GET(List("users")) & get.preview) @@ -80,7 +80,7 @@ class PrismExamples extends PropticsSuite { test("embedding values with prisms") { val composed: Prism[Option[Either[String, Int]], String] = - some[Either[String, Int]] compose left[String, Int] + some[Either[String, Int]] andThen left[String, Int] assertResult(GET(List("users")))(get.review(List("users"))) assertResult(POST(List("users"), "My blog post"))(post.review((List("users"), "My blog post"))) @@ -90,14 +90,14 @@ class PrismExamples extends PropticsSuite { test("extract all Some values from a list") { val input = List("Some".some, "None".some, None, "Option".some, None) - val composed = Fold.fromFoldable[List, Option[String]] compose some[String] + val composed = Fold.fromFoldable[List, Option[String]] andThen some[String] assertResult(List("Some", "None", "Option"))(composed.viewAll(input)) } test("traverse all option's values") { val input = List("Some".some, None, "Option".some) - val composed = Traversal.fromTraverse[List, Option[String]] compose some[String] + val composed = Traversal.fromTraverse[List, Option[String]] andThen some[String] val expected = List("Some[A]".some, None, "Option[A]".some) assertResult(expected)(composed.over(_ |+| "[A]")(input)) diff --git a/example/src/test/scala/optics/ReviewExamples.scala b/example/src/test/scala/optics/ReviewExamples.scala index 4f8bc111e..cec4476be 100644 --- a/example/src/test/scala/optics/ReviewExamples.scala +++ b/example/src/test/scala/optics/ReviewExamples.scala @@ -32,14 +32,14 @@ class ReviewExamples extends PropticsSuite { } test("review will use both constructors of composed optics") { - val eitherFill = right[String, Fill] compose Prism.only[Fill](Solid(Color.white)) + val eitherFill = right[String, Fill] andThen Prism.only[Fill](Solid(Color.white)) assertResult(Right(Solid(Color.white)))(eitherFill.review(())) } test("using Review optic explicitly") { val eitherFillReview = - Review[Either[String, Fill], Fill](_.asRight[String]) compose + Review[Either[String, Fill], Fill](_.asRight[String]) andThen Prism.only[Fill](Solid(Color.white)) assertResult(Right(Solid(Color.white)))(eitherFillReview.review(())) diff --git a/example/src/test/scala/optics/TraversalExamples.scala b/example/src/test/scala/optics/TraversalExamples.scala index 734af0ecf..9a81f6e51 100644 --- a/example/src/test/scala/optics/TraversalExamples.scala +++ b/example/src/test/scala/optics/TraversalExamples.scala @@ -52,14 +52,14 @@ class TraversalExamples extends PropticsSuite { } test("capitalize the title") { - val traversal = stringToChars compose Traversal.takeWhile[List, Char](_ =!= '-') + val traversal = stringToChars andThen Traversal.takeWhile[List, Char](_ =!= '-') val sentence = "traversal - allows you to traverse over a structure" assertResult("TRAVERSAL - allows you to traverse over a structure")(traversal.over(_.toUpper)(sentence)) } test("capitalize the first char of every word") { - val composed = words compose stringToChars compose Traversal.take[List, Char](1) + val composed = words andThen stringToChars andThen Traversal.take[List, Char](1) val sentence = "capitalize the first char of every word" assertResult("Capitalize The First Char Of Every Word")(composed.over(_.toUpper)(sentence)) @@ -68,8 +68,8 @@ class TraversalExamples extends PropticsSuite { test("find all programming languages with higher kinded types") { val hktSupport = Set("Scala", "Haskell") val composed = - Traversal.fromTraverse[List, String] compose - words compose + Traversal.fromTraverse[List, String] andThen + words andThen Traversal.filter[String](hktSupport.contains) val expected = List("Erlang", "F#", "Scala √", "Haskell √") @@ -93,7 +93,7 @@ class TraversalExamples extends PropticsSuite { else List(s"missing @: $email").invalid[String] val both = Traversal_.both[(*, *), List[String], List[String]] - val composed = both compose Traversal.fromTraverse[List, String] + val composed = both andThen Traversal.fromTraverse[List, String] val emails1 = (List("a@b.ai", "b@c.com"), List("c@d.org", "d@e.io")) val emails2 = (List("a@b.ai", "b.com"), List("c@d.org", "d.io")) val bothRes1: Validated[List[String], (List[String], List[String])] = @@ -117,7 +117,7 @@ class TraversalExamples extends PropticsSuite { test("get a specific element from a composition of traversals") { val composed = - (Traversal.fromTraverse[List, List[Int]] compose + (Traversal.fromTraverse[List, List[Int]] andThen Traversal.fromTraverse[List, Int]) .elementAt(6) @@ -129,7 +129,7 @@ class TraversalExamples extends PropticsSuite { } test("replace the second element of a list inside a tuple") { - val composed = _2[String, List[String]] compose Traversal.elementAt[List, String](1) + val composed = _2[String, List[String]] andThen Traversal.elementAt[List, String](1) val expected = ("Bond", List("Connery", "Craig", "Moore")) assertResult(expected)(composed.set("Craig")(("Bond", List("Connery", "Brosnan", "Moore")))) @@ -137,8 +137,8 @@ class TraversalExamples extends PropticsSuite { test("capitalize the first two words of in a sentence") { val composed = - words.take(2) compose - stringToChars compose + words.take(2) andThen + stringToChars andThen Traversal.fromTraverse[List, Char] val sentence = "capitalize the first two words of in a sentence" @@ -149,9 +149,9 @@ class TraversalExamples extends PropticsSuite { test("replace each character of the second word of each sentence in a list") { val composed = - Traversal.fromTraverse[List, String] compose - words.elementAt(1) compose - stringToChars compose + Traversal.fromTraverse[List, String] andThen + words.elementAt(1) andThen + stringToChars andThen Traversal.fromTraverse[List, Char] val list = List("Collapse The Light Into Earth", "Dark Matter", "Heartattack In A Layby") @@ -162,8 +162,8 @@ class TraversalExamples extends PropticsSuite { test("create all possible ways to convert characters to upper case in a word") { val composed = - _1[String, Boolean] compose - stringToChars compose + _1[String, Boolean] andThen + stringToChars andThen Traversal.fromTraverse[List, Char] val expected = List(("ABC", true), ("ABc", true), ("AbC", true), ("Abc", true), ("aBC", true), ("aBc", true), ("abC", true), ("abc", true)) diff --git a/example/src/test/scala/optics/UnsafePartsOfExamples.scala b/example/src/test/scala/optics/UnsafePartsOfExamples.scala index 1a5c292dd..7c62caf79 100644 --- a/example/src/test/scala/optics/UnsafePartsOfExamples.scala +++ b/example/src/test/scala/optics/UnsafePartsOfExamples.scala @@ -7,10 +7,10 @@ import proptics.{ATraversal_, Lens_, Traversal_} class UnsafePartsOfExamples extends PropticsSuite { val traversedTuple1: Traversal_[List[(String, Int)], List[(Boolean, Int)], String, Boolean] = - Traversal_.fromTraverse[List, (String, Int), (Boolean, Int)] compose + Traversal_.fromTraverse[List, (String, Int), (Boolean, Int)] andThen _1P[String, Boolean, Int] val traversedTuple2: ATraversal_[List[(String, Int)], List[(Boolean, Int)], String, Boolean] = - ATraversal_.fromTraverse[List, (String, Int), (Boolean, Int)] compose + ATraversal_.fromTraverse[List, (String, Int), (Boolean, Int)] andThen _1P[String, Boolean, Int] val unsafePartsOfFromTraversal: Lens_[List[(String, Int)], List[(Boolean, Int)], List[String], List[Boolean]] = traversedTuple1.unsafePartsOf diff --git a/law/src/main/scala/proptics/law/AnIndexedLensLaws.scala b/law/src/main/scala/proptics/law/AnIndexedLensLaws.scala index 6f6653eb9..6b294c5a2 100644 --- a/law/src/main/scala/proptics/law/AnIndexedLensLaws.scala +++ b/law/src/main/scala/proptics/law/AnIndexedLensLaws.scala @@ -17,7 +17,6 @@ trait AnIndexedLensLaws[I, S, A] { def composeOver(s: S)(f: (A, I) => A)(g: (A, I) => A): IsEq[S] = anIndexedLens.over(g.tupled)(anIndexedLens.over(f.tupled)(s)) <-> anIndexedLens.over { case (a, i) => g(f(a, i), i) }(s) - def composeSourceLens(s: S): IsEq[S] = (setWhatYouGet _ compose setWhatYouGet)(s) <-> s def composeFocusLens(s: S, a: A): IsEq[A] = (getWhatYouSet(s) _ compose getWhatYouSet(s))(a) <-> a } diff --git a/macros/shared/src/main/scala-2.x/proptics/macros/GenLensMacro.scala b/macros/shared/src/main/scala-2.x/proptics/macros/GenLensMacro.scala index 20081a8b8..a0d60bc37 100644 --- a/macros/shared/src/main/scala-2.x/proptics/macros/GenLensMacro.scala +++ b/macros/shared/src/main/scala-2.x/proptics/macros/GenLensMacro.scala @@ -44,7 +44,7 @@ private[macros] class GenLensMacro(val c: blackbox.Context) { val composedLensesTree = fields .map { case (field, tpe) => q"_root_.proptics.macros.$genLensName[$tpe](_.$field)" } - .reduce((a, b) => q"$a.compose($b)") + .reduce((a, b) => q"$a.andThen($b)") c.Expr[Lens](composedLensesTree) case _ => c.abort(c.enclosingPosition, s"could not focus on field ${show(field.tree)}") diff --git a/profunctor/src/main/scala/proptics/profunctor/Costar.scala b/profunctor/src/main/scala/proptics/profunctor/Costar.scala index faa6ecc19..cfe28df1d 100644 --- a/profunctor/src/main/scala/proptics/profunctor/Costar.scala +++ b/profunctor/src/main/scala/proptics/profunctor/Costar.scala @@ -8,7 +8,7 @@ import cats.syntax.either._ import cats.{Applicative, Apply, CoflatMap, Comonad, Distributive, FlatMap, Functor, Invariant, Monad, ~>} abstract class CostarInstances { - implicit final def composeCostar[F[_]: CoflatMap]: Compose[Costar[F, *, *]] = new Compose[Costar[F, *, *]] { + implicit final def andThenCostar[F[_]: CoflatMap]: Compose[Costar[F, *, *]] = new Compose[Costar[F, *, *]] { override def compose[A, B, C](f: Costar[F, B, C], g: Costar[F, A, B]): Costar[F, A, C] = Costar(Cokleisli(f.run).compose(Cokleisli(g.run)).run) } @@ -17,7 +17,7 @@ abstract class CostarInstances { override def id[A]: Costar[F, A, A] = Costar(ev.extract) override def compose[A, B, C](f: Costar[F, B, C], g: Costar[F, A, B]): Costar[F, A, C] = - composeCostar[F].compose(f, g) + andThenCostar[F].compose(f, g) } implicit final def functorCostar[F[_], C]: Functor[Costar[F, C, *]] = new Functor[Costar[F, C, *]] { diff --git a/project/BuildHelper.scala b/project/BuildHelper.scala index 38939eb92..cd4708815 100644 --- a/project/BuildHelper.scala +++ b/project/BuildHelper.scala @@ -164,13 +164,13 @@ object BuildHelper { .value, ScalaUnidoc / unidoc / scalacOptions ++= Seq( "-doc-source-url", - s"https://github.com/sagifogel/Proptics/tree/v0.3.0€{FILE_PATH}.scala", + s"https://github.com/sagifogel/Proptics/tree/v0.3.1€{FILE_PATH}.scala", "-sourcepath", (LocalRootProject / baseDirectory).value.getAbsolutePath, "-doc-title", "Proptics", "-doc-version", - "v0.3.0" + "v0.3.1" ) ) diff --git a/test/shared/src/test/scala/proptics/specs/ALensSpec.scala b/test/shared/src/test/scala/proptics/specs/ALensSpec.scala index bf97e7119..6f1137e25 100644 --- a/test/shared/src/test/scala/proptics/specs/ALensSpec.scala +++ b/test/shared/src/test/scala/proptics/specs/ALensSpec.scala @@ -23,11 +23,11 @@ class ALensSpec extends PropticsSuite { f1(int) === f2(int) } } - val firstLevelGLens: ALens[Person, String] = GALens[Person](_.name) - val leafLevelGLens: ALens[Person, Int] = GALens[Person](_.address.street.number) + val firstLevelGALens: ALens[Person, String] = GALens[Person](_.name) + val leafLevelGALens: ALens[Person, Int] = GALens[Person](_.address.street.number) - checkAll("GALens[Person, String] top level gen", ALensTests(firstLevelGLens).aLens) - checkAll("GALens[Person, Int] leaf level gen", ALensTests(leafLevelGLens).aLens) + checkAll("GALens[Person, String] top level gen", ALensTests(firstLevelGALens).aLens) + checkAll("GALens[Person, Int] leaf level gen", ALensTests(leafLevelGALens).aLens) checkAll("ALens[Int, Int] id", ALensTests(ALens.id[Int]).aLens) checkAll("ALens[Whole, Int] apply", ALensTests(wholeLens).aLens) checkAll("ALens[Whole, Int] asLens", LensTests(wholeLens.asLens).lens) diff --git a/test/shared/src/test/scala/proptics/specs/ATraversalSpec.scala b/test/shared/src/test/scala/proptics/specs/ATraversalSpec.scala index 685834fc9..89b6e411f 100644 --- a/test/shared/src/test/scala/proptics/specs/ATraversalSpec.scala +++ b/test/shared/src/test/scala/proptics/specs/ATraversalSpec.scala @@ -337,18 +337,18 @@ class ATraversalSpec extends PropticsSuite { test("filter using fold") { val filterFold: Fold_[Whole, Whole, Int, Int] = - Getter[Whole, Int](_.part) compose + Getter[Whole, Int](_.part) andThen Prism.fromPartial[Int, Int] { case i if i < 5 => i }(identity) - val traversal = ATraversal.fromTraverse[List, Whole] compose ATraversal.filter(filterFold) + val traversal = ATraversal.fromTraverse[List, Whole] andThen ATraversal.filter(filterFold) traversal.viewAll(List(Whole(1), Whole(9), Whole(2))) shouldEqual List(Whole(1), Whole(2)) } test("filter using traversal") { val filterTraversal = - Lens[Whole, Int](_.part)(const(i => Whole(i))) compose + Lens[Whole, Int](_.part)(const(i => Whole(i))) andThen Prism.fromPartial[Int, Int] { case i if i < 5 => i }(identity) - val traversal = ATraversal.fromTraverse[List, Whole] compose ATraversal.filter(filterTraversal.asFold) + val traversal = ATraversal.fromTraverse[List, Whole] andThen ATraversal.filter(filterTraversal.asFold) traversal.viewAll(List(Whole(1), Whole(9), Whole(2))) shouldEqual List(Whole(1), Whole(2)) } diff --git a/test/shared/src/test/scala/proptics/specs/FoldSpec.scala b/test/shared/src/test/scala/proptics/specs/FoldSpec.scala index df30a832b..22b902321 100644 --- a/test/shared/src/test/scala/proptics/specs/FoldSpec.scala +++ b/test/shared/src/test/scala/proptics/specs/FoldSpec.scala @@ -384,13 +384,13 @@ class FoldSpec extends PropticsSuite { composed.foldMap(list)(_._1) shouldEqual List(1) } - test("compose with IndexedTraversal") { - (Fold[List[Int], List[Int]](identity) compose + test("andThen with IndexedTraversal") { + (Fold[List[Int], List[Int]](identity) andThen IndexedTraversal.fromTraverse[List, Int]).foldMap(list) { case (_, i) => List(i) } shouldEqual list.zipWithIndex.map(_._2) } - test("andThen with IndexedTraversal") { - (Fold[List[Int], List[Int]](identity) andThen + test("compose with IndexedTraversal") { + (Fold[List[Int], List[Int]](identity) compose IndexedTraversal.fromTraverse[List, List[Int]]).foldMap(list.map(List(_))) { case (_, i) => List(i) } shouldEqual list.zipWithIndex.map(_._2) } @@ -464,18 +464,18 @@ class FoldSpec extends PropticsSuite { test("filter using fold") { val traversal = - Getter[Whole, Int](_.part) compose + Getter[Whole, Int](_.part) andThen Prism.fromPartial[Int, Int] { case i if i < 5 => i }(identity) - val fold = Fold.fromFoldable[List, Whole] compose Fold.filter(traversal) + val fold = Fold.fromFoldable[List, Whole] andThen Fold.filter(traversal) fold.viewAll(List(Whole(1), Whole(9), Whole(2))) shouldEqual List(Whole(1), Whole(2)) } test("filter using traversal") { val traversal = - Lens[Whole, Int](_.part)(const(i => Whole(i))) compose + Lens[Whole, Int](_.part)(const(i => Whole(i))) andThen Prism.fromPartial[Int, Int] { case i if i < 5 => i }(identity) - val fold = Fold.fromFoldable[List, Whole] compose Fold.filter(traversal) + val fold = Fold.fromFoldable[List, Whole] andThen Fold.filter(traversal) fold.viewAll(List(Whole(1), Whole(9), Whole(2))) shouldEqual List(Whole(1), Whole(2)) } diff --git a/test/shared/src/test/scala/proptics/specs/GetterSpec.scala b/test/shared/src/test/scala/proptics/specs/GetterSpec.scala index 560980a84..8d6df2355 100644 --- a/test/shared/src/test/scala/proptics/specs/GetterSpec.scala +++ b/test/shared/src/test/scala/proptics/specs/GetterSpec.scala @@ -171,15 +171,15 @@ class GetterSpec extends PropticsSuite { composed.view(List(1, 2, 3)) shouldEqual ((List(1), 0)) } - test("compose with IndexedTraversal") { + test("andThen with IndexedTraversal") { val composed = - Getter[List[Int], List[Int]](identity) compose IndexedTraversal.fromTraverse[List, Int] + Getter[List[Int], List[Int]](identity) andThen IndexedTraversal.fromTraverse[List, Int] composed.foldMap(list) { case (_, i) => List(i) } shouldEqual list.zipWithIndex.map(_._2) } - test("andThen with IndexedTraversal") { + test("compose with IndexedTraversal") { val composed = - Getter[List[Int], List[Int]](identity) andThen IndexedTraversal.fromTraverse[List, List[Int]] + Getter[List[Int], List[Int]](identity) compose IndexedTraversal.fromTraverse[List, List[Int]] composed.foldMap(list.map(List(_))) { case (_, i) => List(i) } shouldEqual list.zipWithIndex.map(_._2) } diff --git a/test/shared/src/test/scala/proptics/specs/IndexedLensSpec.scala b/test/shared/src/test/scala/proptics/specs/IndexedLensSpec.scala index c9f311b3b..ace42de7e 100644 --- a/test/shared/src/test/scala/proptics/specs/IndexedLensSpec.scala +++ b/test/shared/src/test/scala/proptics/specs/IndexedLensSpec.scala @@ -136,17 +136,17 @@ class IndexedLensSpec extends PropticsSuite { } test("compose with Getter") { - val composed = nelIndexedLens compose Getter.id[Int] + val composed = nelIndexedLens andThen Getter.id[Int] composed.view(NonEmptyList.fromListUnsafe(List(1, 2, 3))) shouldEqual ((1, 0)) } - test("compose with Fold") { - val composed = nelIndexedLens compose Fold.id[Int] + test("andThen with Fold") { + val composed = nelIndexedLens andThen Fold.id[Int] composed.foldMap(NonEmptyList.fromListUnsafe(List(0, 1, 2))) { case (_, i) => List(i) } shouldEqual List(0) } - test("andThen with Fold") { - val composed = nelIndexedLens andThen Fold.id[NonEmptyList[Int]] + test("compose with Fold") { + val composed = nelIndexedLens compose Fold.id[NonEmptyList[Int]] composed.foldMap(NonEmptyList.fromListUnsafe(List(0, 1, 2))) { case (_, i) => List(i) } shouldEqual List(0) } diff --git a/test/shared/src/test/scala/proptics/specs/IndexedTraversalSpec.scala b/test/shared/src/test/scala/proptics/specs/IndexedTraversalSpec.scala index fd3c92817..0c814162a 100644 --- a/test/shared/src/test/scala/proptics/specs/IndexedTraversalSpec.scala +++ b/test/shared/src/test/scala/proptics/specs/IndexedTraversalSpec.scala @@ -342,13 +342,13 @@ class IndexedTraversalSpec extends PropticsSuite { .viewAll(nel) shouldEqual indexedList.map(_.map(_.toString)) } - test("compose with Fold") { - val composed = listFromTraversalWithIndex compose Fold.id[Int] + test("andThen with Fold") { + val composed = listFromTraversalWithIndex andThen Fold.id[Int] composed.foldMap(List(0, 1, 2)) { case (_, i) => List(i) } shouldEqual List(0, 1, 2) } - test("andThen with Fold") { - val composed = listFromTraversalWithIndex andThen Fold.id[List[Int]] + test("compose with Fold") { + val composed = listFromTraversalWithIndex compose Fold.id[List[Int]] composed.foldMap(List(0, 1, 2)) { case (_, i) => List(i) } shouldEqual List(0, 1, 2) } diff --git a/test/shared/src/test/scala/proptics/specs/LensSpec.scala b/test/shared/src/test/scala/proptics/specs/LensSpec.scala index 7deb32bcb..61cb8d73c 100644 --- a/test/shared/src/test/scala/proptics/specs/LensSpec.scala +++ b/test/shared/src/test/scala/proptics/specs/LensSpec.scala @@ -18,14 +18,14 @@ import proptics.{ATraversal, ATraversal_, Getter, IndexedGetter, Iso, Lens, Lens class LensSpec extends PropticsSuite { val wholeLens: Lens[Whole, Int] = Lens[Whole, Int](_.part)(w => i => w.copy(part = i)) - val traversedTuple1: Traversal[List[(String, Int)], String] = Traversal.fromTraverse[List, (String, Int)] compose _1[String, Int] - val aTraversedTuple1: ATraversal[List[(String, Int)], String] = ATraversal.fromTraverse[List, (String, Int)] compose _1[String, Int] - val traversedTuple2: Traversal[List[(String, Double)], Double] = Traversal.fromTraverse[List, (String, Double)] compose _2[String, Double] + val traversedTuple1: Traversal[List[(String, Int)], String] = Traversal.fromTraverse[List, (String, Int)] andThen _1[String, Int] + val aTraversedTuple1: ATraversal[List[(String, Int)], String] = ATraversal.fromTraverse[List, (String, Int)] andThen _1[String, Int] + val traversedTuple2: Traversal[List[(String, Double)], Double] = Traversal.fromTraverse[List, (String, Double)] andThen _2[String, Double] val traversedTuple3: Traversal_[List[(String, Int)], List[(Boolean, Int)], String, Boolean] = - Traversal_.fromTraverse[List, (String, Int), (Boolean, Int)] compose _1P[String, Boolean, Int] - val aTraversedTuple2: ATraversal[List[(String, Double)], Double] = ATraversal.fromTraverse[List, (String, Double)] compose _2[String, Double] + Traversal_.fromTraverse[List, (String, Int), (Boolean, Int)] andThen _1P[String, Boolean, Int] + val aTraversedTuple2: ATraversal[List[(String, Double)], Double] = ATraversal.fromTraverse[List, (String, Double)] andThen _2[String, Double] val aTraversedTuple3: ATraversal_[List[(String, Int)], List[(Boolean, Int)], String, Boolean] = - ATraversal_.fromTraverse[List, (String, Int), (Boolean, Int)] compose _1P[String, Boolean, Int] + ATraversal_.fromTraverse[List, (String, Int), (Boolean, Int)] andThen _1P[String, Boolean, Int] val partsOfFromTraversal1: Lens[List[(String, Int)], List[String]] = traversedTuple1.partsOf val partsOfFromATraversal1: Lens[List[(String, Int)], List[String]] = aTraversedTuple1.partsOf val partsOfFromTraversal2: Lens[List[(String, Double)], List[Double]] = traversedTuple2.partsOf diff --git a/test/shared/src/test/scala/proptics/specs/TraversalSpec.scala b/test/shared/src/test/scala/proptics/specs/TraversalSpec.scala index e6d5dbad1..eca05fd4d 100644 --- a/test/shared/src/test/scala/proptics/specs/TraversalSpec.scala +++ b/test/shared/src/test/scala/proptics/specs/TraversalSpec.scala @@ -334,18 +334,18 @@ class TraversalSpec extends PropticsSuite { test("filter using fold") { val filterFold: Fold_[Whole, Whole, Int, Int] = - Getter[Whole, Int](_.part) compose + Getter[Whole, Int](_.part) andThen Prism.fromPartial[Int, Int] { case i if i < 5 => i }(identity) - val traversal = Traversal.fromTraverse[List, Whole] compose Traversal.filter(filterFold) + val traversal = Traversal.fromTraverse[List, Whole] andThen Traversal.filter(filterFold) traversal.viewAll(List(Whole(1), Whole(9), Whole(2))) shouldEqual List(Whole(1), Whole(2)) } test("filter using traversal") { val filterTraversal = - Lens[Whole, Int](_.part)(const(i => Whole(i))) compose + Lens[Whole, Int](_.part)(const(i => Whole(i))) andThen Prism.fromPartial[Int, Int] { case i if i < 5 => i }(identity) - val traversal = Traversal.fromTraverse[List, Whole] compose Traversal.filter(filterTraversal.asFold) + val traversal = Traversal.fromTraverse[List, Whole] andThen Traversal.filter(filterTraversal.asFold) traversal.viewAll(List(Whole(1), Whole(9), Whole(2))) shouldEqual List(Whole(1), Whole(2)) }