All Downloads are FREE. Search and download functionalities are using the official Maven repository.

zio.prelude.experimental.Subtract.scala Maven / Gradle / Ivy

There is a newer version: 1.0.0-RC34
Show newest version
package zio.prelude
package experimental
import zio.prelude.newtypes.Sum

trait Subtract[A] extends DistributiveProd[A] {
  def Sum: Inverse[Sum[A]]
  def subtract(l: => A, r: => A): A = Sum.inverse(newtypes.Sum(l), newtypes.Sum(r))
}

trait SubtractSyntax {

  /**
   * Provides infix syntax for subtracting two values.
   */
  implicit class SubtractOps[A](private val l: A) {

    /**
     * A symbolic alias for `subtract`.
     */
    def ---(r: => A)(implicit subtract: Subtract[A]): A =
      subtract.subtract(l, r)

    /**
     * Subtract two values.
     */
    def subtract(r: => A)(implicit subtract: Subtract[A]): A =
      subtract.subtract(l, r)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy