Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer SAMs whenever possible #37

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions core/shared/src/main/scala/reftree/core/RefTree.scala
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ trait ToRefTree[A] { self =>
object ToRefTree extends CollectionInstances with HackedCollectionInstances with GenericInstances {

/** A shorthand method for creating [[ToRefTree]] instances */
def apply[A](toRefTree: A => RefTree): ToRefTree[A] = new ToRefTree[A] {
def refTree(value: A) = toRefTree(value)
}
def apply[A](toRefTree: A => RefTree): ToRefTree[A] = (value: A) => toRefTree(value)

def const[A](refTree: => RefTree): ToRefTree[A] =
(_: A) => refTree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ trait SemiInterpolation[A] { self =>
}

object SemiInterpolation {
def apply[A](f: (A, Double) => A): SemiInterpolation[A] = new SemiInterpolation[A] {
def apply(value: A, t: Double) = f(value, t)
}
def apply[A](f: (A, Double) => A): SemiInterpolation[A] = (value: A, t: Double) => f(value, t)
}

/**
Expand Down Expand Up @@ -213,9 +211,8 @@ trait Interpolation[A] { self =>

object Interpolation {
/** A shorthand for constructing interpolations */
def apply[A](f: (A, A, Double) => A): Interpolation[A] = new Interpolation[A] {
def apply(left: A, right: A, t: Double): A = f(left, right, t)
}
def apply[A](f: (A, A, Double) => A): Interpolation[A] =
(left: A, right: A, t: Double) => f(left, right, t)

/** A basic linear interpolation for doubles */
val double = Interpolation[Double]((l, r, t) => l * (1 - t) + r * t)
Expand Down
4 changes: 1 addition & 3 deletions core/shared/src/main/scala/reftree/geometry/Point.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ trait Translatable[A] {
}

object Translatable {
def apply[A](f: (A, Point) => A): Translatable[A] = new Translatable[A] {
def translate(value: A, delta: Point) = f(value, delta)
}
def apply[A](f: (A, Point) => A): Translatable[A] = (value: A, delta: Point) => f(value, delta)

implicit def `List Translatable`[A](implicit t: Translatable[A]): Translatable[List[A]] =
Translatable((value, delta) => value.map(t.translate(_, delta)))
Expand Down