trait Align[F[_]] extends Serializable
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
- Source
- Align.scala
- Alphabetic
- By Inheritance
- Align
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def align[A, B](fa: F[A], fb: F[B]): F[Ior[A, B]]
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.implicits._ 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))
- abstract def functor: Functor[F]
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def alignCombine[A](fa1: F[A], fa2: F[A])(implicit arg0: Semigroup[A]): F[A]
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.implicits._ scala> Align[List].alignCombine(List(1, 2), List(10, 11, 12)) res0: List[Int] = List(11, 13, 12)
- def alignMergeWith[A](fa1: F[A], fa2: F[A])(f: (A, A) => A): F[A]
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.implicits._ scala> Align[List].alignMergeWith(List(1, 2), List(10, 11, 12))(_ + _) res0: List[Int] = List(11, 13, 12)
- def alignWith[A, B, C](fa: F[A], fb: F[B])(f: (Ior[A, B]) => C): F[C]
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.implicits._ scala> Align[List].alignWith(List(1, 2), List(10, 11, 12))(_.mergeLeft) res0: List[Int] = List(1, 2, 12)
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def padZip[A, B](fa: F[A], fb: F[B]): F[(Option[A], Option[B])]
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.implicits._ scala> Align[List].padZip(List(1, 2), List(10)) res0: List[(Option[Int], Option[Int])] = List((Some(1),Some(10)), (Some(2),None))
- def padZipWith[A, B, C](fa: F[A], fb: F[B])(f: (Option[A], Option[B]) => C): F[C]
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.implicits._ scala> Align[List].padZipWith(List(1, 2), List(10, 11, 12))(_ |+| _) res0: List[Option[Int]] = List(Some(11), Some(13), Some(12))
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def zipAll[A, B](fa: F[A], fb: F[B], a: A, b: B): F[(A, B)]
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.implicits._ scala> Align[List].zipAll(List(1, 2), List(10, 11, 12), 20, 21) res0: List[(Int, Int)] = List((1,10), (2,11), (20,12))