Align
supports zipping together structures with different shapes, holding the results from either or both structures in an Ior
.
Must obey the laws in cats.laws.AlignLaws
Attributes
- Companion
- object
- Source
- Align.scala
- Graph
-
- Supertypes
Members list
Value members
Abstract methods
Pairs elements of two structures along the union of their shapes, using Ior
to hold the results.
Pairs elements of two structures along the union of their shapes, using Ior
to hold the results.
Example:
scala> import cats.syntax.all._
scala> import cats.data.Ior
scala> Align[List].align(List(1, 2), List(10, 11, 12))
res0: List[Ior[Int, Int]] = List(Both(1,10), Both(2,11), Right(12))
Attributes
- Source
- Align.scala
Attributes
- Source
- Align.scala
Concrete methods
Align two structures with the same element, combining results according to their semigroup instances.
Align two structures with the same element, combining results according to their semigroup instances.
Example:
scala> import cats.syntax.all._
scala> Align[List].alignCombine(List(1, 2), List(10, 11, 12))
res0: List[Int] = List(11, 13, 12)
Attributes
- Source
- Align.scala
Align two structures with the same element, combining results according to the given function.
Align two structures with the same element, combining results according to the given function.
Example:
scala> import cats.syntax.all._
scala> Align[List].alignMergeWith(List(1, 2), List(10, 11, 12))(_ + _)
res0: List[Int] = List(11, 13, 12)
Attributes
- Source
- Align.scala
Combines elements similarly to align
, using the provided function to compute the results.
Combines elements similarly to align
, using the provided function to compute the results.
Example:
scala> import cats.syntax.all._
scala> Align[List].alignWith(List(1, 2), List(10, 11, 12))(_.mergeLeft)
res0: List[Int] = List(1, 2, 12)
Attributes
- Source
- Align.scala
Same as align
, but forgets from the type that one of the two elements must be present.
Same as align
, but forgets from the type that one of the two elements must be present.
Example:
scala> import cats.syntax.all._
scala> Align[List].padZip(List(1, 2), List(10))
res0: List[(Option[Int], Option[Int])] = List((Some(1),Some(10)), (Some(2),None))
Attributes
- Source
- Align.scala
Same as alignWith
, but forgets from the type that one of the two elements must be present.
Same as alignWith
, but forgets from the type that one of the two elements must be present.
Example:
scala> import cats.syntax.all._
scala> Align[List].padZipWith(List(1, 2), List(10, 11, 12))(_ |+| _)
res0: List[Option[Int]] = List(Some(11), Some(13), Some(12))
Attributes
- Source
- Align.scala
Pairs elements of two structures along the union of their shapes, using placeholders for missing values.
Pairs elements of two structures along the union of their shapes, using placeholders for missing values.
Example:
scala> import cats.syntax.all._
scala> Align[List].zipAll(List(1, 2), List(10, 11, 12), 20, 21)
res0: List[(Int, Int)] = List((1,10), (2,11), (20,12))
Attributes
- Source
- Align.scala