Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Commit

Permalink
Add Suffix.eyrieConvertibleBasedArgumentInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
sd-yip committed Feb 13, 2019
1 parent 0b672d1 commit 9f7d622
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
20 changes: 18 additions & 2 deletions core/src/main/scala/eyrie/instances/SuffixInstances.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@ import eyrie.{Emptiness, False}

private[eyrie]
trait SuffixInstances extends LowPrioritySuffixInstances {
implicit def eyrieConvertibleBasedInstance[A, B, C](
implicit def eyrieConvertibleBasedArgumentInstance[A, B, C](
implicit
B: Convertible.ByQuality.Aux[Emptiness[False], C, B],
A: Suffix[A, C]
): Suffix[A, B] =
new Suffix[A, B] {
override
def endsWith: (A, B) => Boolean =
(a, b) => B.narrow(b).fold(true)(
A.endsWith(a, _)
)
}
}

private[eyrie]
trait LowPrioritySuffixInstances extends LowPrioritySuffixInstances1 {
implicit def eyrieConvertibleBasedReceiverInstance[A, B, C](
implicit
A: Convertible.ByQuality.Aux[Emptiness[False], C, A],
C: Suffix[C, B]
Expand All @@ -20,7 +36,7 @@ trait SuffixInstances extends LowPrioritySuffixInstances {
}

private[eyrie]
trait LowPrioritySuffixInstances {
trait LowPrioritySuffixInstances1 {
implicit def eyrieSubdivisionBasedInstance[A, B, L, R](
implicit
A: Subdivision[A, L, R],
Expand Down
21 changes: 21 additions & 0 deletions file/src/test/scala/eyrie/file/test/SuffixSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,25 @@ class SuffixSpec extends FreeSpec {
filePath.endsWith(relativeFile)
}
}

"RelativeFile" - {
"endsWith(Relative) should work" in {
relativeFile.endsWith(relative)
}
}
"AbsoluteFile" - {
"endsWith(Relative) should work" in {
absoluteFile.endsWith(relative)
}
}
"NonEmpty" - {
"endsWith(Relative) should work" in {
nonEmpty.endsWith(relative)
}
}
"FilePath" - {
"endsWith(Relative) should work" in {
filePath.endsWith(relative)
}
}
}

0 comments on commit 9f7d622

Please sign in to comment.