scalan.primitives.Equal.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sigma-state_2.12 Show documentation
Show all versions of sigma-state_2.12 Show documentation
Interpreter of a Sigma-State language
The newest version!
package scalan.primitives
import scalan.{Base, Scalan}
import scala.annotation.unused
trait Equal extends Base { self: Scalan =>
/** Binary operation representing structural equality between arguments. */
case class Equals[A: Elem]() extends BinOp[A, Boolean]("==") {
override def applySeq(x: A, y: A): Boolean = equalValues[A](x, y)
}
/** Binary operation representing structural inequality between arguments. */
case class NotEquals[A: Elem]() extends BinOp[A, Boolean]("!=") {
override def applySeq(x: A, y: A): Boolean = !equalValues[A](x, y)
}
protected def equalValues[A](x: Any, y: Any)(implicit @unused eA: Elem[A]) = x == y
/** Extension methods to construct ApplyBinOp nodes */
implicit class EqualOps[A](x: Ref[A]) {
implicit private val eA: Elem[A] = x.elem
/** Apply Equals binary operation and return Ref to ApplyBinOp node. */
def ===(y: Ref[A]): Ref[Boolean] = Equals[A].apply(x, y)
/** Apply NotEquals binary operation and return Ref to ApplyBinOp node. */
def !==(y: Ref[A]): Ref[Boolean] = NotEquals[A].apply(x, y)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy