tofu.syntax.optics.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tofu-core_2.13 Show documentation
Show all versions of tofu-core_2.13 Show documentation
Opinionated Set of tool for functional programming in scala
package tofu.syntax
import cats.arrow.Category
object optics {
//version of cats.syntax.compose with subtyping support
implicit class OpticOps[T[_, _], A, B](val tab: T[A, B]) extends AnyVal {
def >>>[Q[x, y] >: T[x, y], C](qbc: Q[B, C])(implicit cat: Category[Q]): Q[A, C] =
cat.compose(qbc, tab)
def andThen[Q[x, y] >: T[x, y], C](qbc: Q[B, C])(implicit cat: Category[Q]): Q[A, C] =
cat.compose(qbc, tab)
def <<<[Q[x, y] >: T[x, y], C](qbc: Q[C, A])(implicit cat: Category[Q]): Q[C, B] =
cat.compose(tab, qbc)
def compose[Q[x, y] >: T[x, y], C](qbc: Q[C, A])(implicit cat: Category[Q]): Q[C, B] =
cat.compose(tab, qbc)
}
}