monocle
package monocle
- Source
- package.scala
- Alphabetic
- By Inheritance
- monocle
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- type AppliedFold[S, A] = monocle.syntax.AppliedFold[S, A]
- type AppliedGetter[S, A] = monocle.syntax.AppliedGetter[S, A]
- type AppliedIso[S, A] = AppliedPIso[S, S, A, A]
- type AppliedLens[S, A] = AppliedPLens[S, S, A, A]
- type AppliedOptional[S, A] = AppliedPOptional[S, S, A, A]
- type AppliedPrism[S, A] = AppliedPPrism[S, S, A, A]
- type AppliedSetter[S, A] = AppliedPSetter[S, S, A, A]
- type AppliedTraversal[S, A] = AppliedPTraversal[S, S, A, A]
- trait Fold[S, A] extends Serializable
A Fold can be seen as a Getter with many targets or a weaker PTraversal which cannot modify its target.
- sealed abstract class FoldInstances extends AnyRef
- final case class FoldSyntax[S, A](self: Fold[S, A]) extends AnyVal with Product with Serializable
Extension methods for Fold
- trait Getter[S, A] extends Fold[S, A]
A Getter can be seen as a glorified get method between a type S and a type A.
- sealed abstract class GetterInstances extends GetterInstances0
- sealed abstract class GetterInstances0 extends AnyRef
- final case class GetterSyntax[S, A](self: Getter[S, A]) extends AnyVal with Product with Serializable
Extension methods for Fold
- type Iso[S, A] = PIso[S, S, A, A]
- sealed abstract class IsoInstances extends AnyRef
- final case class IsoSyntax[S, A](self: Iso[S, A]) extends AnyVal with Product with Serializable
Extension methods for monomorphic Iso
- type Lens[S, A] = PLens[S, S, A, A]
- sealed abstract class LensInstances extends AnyRef
- final case class LensSyntax[S, A](self: Lens[S, A]) extends AnyVal with Product with Serializable
Extension methods for monomorphic Lens
- type Optional[S, A] = POptional[S, S, A, A]
- sealed abstract class OptionalInstances extends AnyRef
- final case class OptionalSyntax[S, A](self: Optional[S, A]) extends AnyVal with Product with Serializable
Extension methods for monomorphic Optional
- trait PIso[S, T, A, B] extends PLens[S, T, A, B] with PPrism[S, T, A, B]
Iso is a type alias for PIso where
S
=A
andT
=B
:Iso is a type alias for PIso where
S
=A
andT
=B
:type Iso[S, A] = PIso[S, S, A, A]
An Iso defines an isomorphism between a type S and A:
get --------------------> S A <-------------------- reverseGet
A PIso allows to lift a function
f: A => B
toS => T
and a functiong: T => S
toB => A
g S T S <-------- T | ↑ | ↑ | | | | get | | reverseGet reverse.reverseGet | | reverse.get | | | | ↓ f | ↓ | A --------> B A B
A PIso is also a valid Getter, Fold, PLens, PPrism, POptional, PTraversal and PSetter
- S
the source of a PIso
- T
the modified source of a PIso
- A
the target of a PIso
- B
the modified target of a PIso
- See also
- final case class PIsoSyntax[S, T, A, B](self: PIso[S, T, A, B]) extends AnyVal with Product with Serializable
- trait PLens[S, T, A, B] extends POptional[S, T, A, B] with Getter[S, A]
A PLens can be seen as a pair of functions:
A PLens can be seen as a pair of functions:
get: S => A
i.e. from anS
, we can extract anA
set: (B, S) => T
i.e. if we replace anA
by aB
in anS
, we obtain aT
A PLens could also be defined as a weaker PIso where replace requires an additional parameter than reverseGet.
PLens stands for Polymorphic Lens as it replace and modify methods change a type
A
toB
andS
toT
. Lens is a type alias for PLens restricted to monomorphic updates:type Lens[S, A] = PLens[S, S, A, A]
A PLens is also a valid Getter, Fold, POptional, PTraversal and PSetter
Typically a PLens or Lens can be defined between a Product (e.g. case class, tuple, HList) and one of its component.
- S
the source of a PLens
- T
the modified source of a PLens
- A
the target of a PLens
- B
the modified target of a PLens
- See also
- final case class PLensSyntax[S, T, A, B](self: PLens[S, T, A, B]) extends AnyVal with Product with Serializable
- trait POptional[S, T, A, B] extends PTraversal[S, T, A, B]
A POptional can be seen as a pair of functions:
A POptional can be seen as a pair of functions:
getOrModify: S => Either[T, A]
replace : (B, S) => T
A POptional could also be defined as a weaker PLens and weaker PPrism
POptional stands for Polymorphic Optional as it replace and modify methods change a type
A
toB
andS
toT
. Optional is a type alias for POptional restricted to monomorphic updates:type Optional[S, A] = POptional[S, S, A, A]
- S
the source of a POptional
- T
the modified source of a POptional
- A
the target of a POptional
- B
the modified target of a POptional
- See also
- final case class POptionalSyntax[S, T, A, B](self: POptional[S, T, A, B]) extends AnyVal with Product with Serializable
- trait PPrism[S, T, A, B] extends POptional[S, T, A, B]
A PPrism can be seen as a pair of functions:
A PPrism can be seen as a pair of functions:
getOrModify: S => Either[T, A]
reverseGet : B => T
A PPrism could also be defined as a weaker PIso where get can fail.
Typically a PPrism or Prism encodes the relation between a Sum or CoProduct type (e.g. sealed trait) and one of its element.
PPrism stands for Polymorphic Prism as it replace and modify methods change a type
A
toB
andS
toT
. Prism is a type alias for PPrism where the type of target cannot be modified:type Prism[S, A] = PPrism[S, S, A, A]
A PPrism is also a valid Fold, POptional, PTraversal and PSetter
- S
the source of a PPrism
- T
the modified source of a PPrism
- A
the target of a PPrism
- B
the modified target of a PPrism
- See also
- final case class PPrismSyntax[S, T, A, B](self: PPrism[S, T, A, B]) extends AnyVal with Product with Serializable
- trait PSetter[S, T, A, B] extends Serializable
A PSetter is a generalisation of Functor map:
A PSetter is a generalisation of Functor map:
map: (A => B) => F[A] => F[B]
modify: (A => B) => S => T
PSetter stands for Polymorphic Setter as it replace and modify methods change a type
A
toB
andS
toT
. Setter is a type alias for PSetter restricted to monomorphic updates:type Setter[S, A] = PSetter[S, S, A, A]
PTraversal, POptional, PPrism, PLens and PIso are valid PSetter
- S
the source of a PSetter
- T
the modified source of a PSetter
- A
the target of a PSetter
- B
the modified target of a PSetter
- See also
- final case class PSetterSyntax[S, T, A, B](self: PSetter[S, T, A, B]) extends AnyVal with Product with Serializable
- trait PTraversal[S, T, A, B] extends PSetter[S, T, A, B] with Fold[S, A]
A PTraversal can be seen as a POptional generalised to 0 to n targets where n can be infinite.
A PTraversal can be seen as a POptional generalised to 0 to n targets where n can be infinite.
PTraversal stands for Polymorphic Traversal as it replace and modify methods change a type
A
toB
andS
toT
. Traversal is a type alias for PTraversal restricted to monomorphic updates:type Traversal[S, A] = PTraversal[S, S, A, A]
- S
the source of a PTraversal
- T
the modified source of a PTraversal
- A
the target of a PTraversal
- B
the modified target of a PTraversal
- See also
- final case class PTraversalSyntax[S, T, A, B](self: PTraversal[S, T, A, B]) extends AnyVal with Product with Serializable
- type Prism[S, A] = PPrism[S, S, A, A]
- sealed abstract class PrismInstances extends AnyRef
- final case class PrismSyntax[S, A](self: Prism[S, A]) extends AnyVal with Product with Serializable
- type Setter[S, A] = PSetter[S, S, A, A]
- sealed abstract class SetterInstances extends AnyRef
- final case class SetterSyntax[S, A](self: Setter[S, A]) extends AnyVal with Product with Serializable
Extension methods for monomorphic Setter
- type Traversal[S, A] = PTraversal[S, S, A, A]
- sealed abstract class TraversalInstances extends AnyRef
- final case class TraversalSyntax[S, A](self: Traversal[S, A]) extends AnyVal with Product with Serializable
Extension methods for monomorphic Traversal
Value Members
- object Fold extends FoldInstances with Serializable
- object Getter extends GetterInstances with Serializable
- object Iso
- object Lens
- object Optional
- object PIso extends IsoInstances with Serializable
- object PLens extends LensInstances with Serializable
- object POptional extends OptionalInstances with Serializable
- object PPrism extends PrismInstances with Serializable
- object PSetter extends SetterInstances with Serializable
- object PTraversal extends TraversalInstances with Serializable
- object Prism
- object Setter
- object Traversal