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

scala.meta.contrib.implicits.Equality.scala Maven / Gradle / Ivy

There is a newer version: 4.12.2
Show newest version
package scala.meta.contrib.implicits

import scala.meta.Tree
import scala.meta.contrib.equality.Equal
import scala.meta.contrib.equality.Structurally
import scala.meta.contrib.equality.TreeEquality

import scala.language.higherKinds
import scala.language.implicitConversions

trait Equality {

  /** Helper to default tree equality to use structural equality. */
  implicit def treeToContainer(tree: Tree): Structurally[Tree] = Structurally.toStructural(tree)

  type Structurally[A <: Tree] = scala.meta.contrib.equality.Structurally[A]
  type Syntactically[A <: Tree] = scala.meta.contrib.equality.Syntactically[A]

  implicit class XtensionTreeEquality[A <: Tree](a: A) {

    @inline
    def isEqual[F[x <: Tree] <: TreeEquality[x]](
        b: A
    )(implicit conv: Tree => F[Tree], eqEv: Equal[F[Tree]]): Boolean =
      (a eq b) || eqEv.isEqual(conv(a), conv(b))
  }
}

object Equality extends Equality




© 2015 - 2025 Weber Informatics LLC | Privacy Policy