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

Commit

Permalink
Enable rootOption on FilePath
Browse files Browse the repository at this point in the history
  • Loading branch information
sd-yip committed Jan 27, 2019
1 parent a7426c4 commit c00b469
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import eyrie.ops.Convertible

private[eyrie]
trait ConvertibleByAttributeInstances {
implicit def eyrieByAttributeInstance[Attr[_], A, B](
implicit def eyrieConvertibleByAttributeInstance[Attr[_], A, B](
implicit F: Convertible.Aux[Attr, _, A, B]
): Convertible.ByAttribute.Aux[Attr, A, B] =
new Convertible.ByAttribute[Attr, A] {
Expand All @@ -23,7 +23,7 @@ trait ConvertibleByAttributeInstances {

private[eyrie]
trait ConvertibleByQualityInstances {
implicit def eyrieByQualityInstance[Attr[_], Param, A, B](
implicit def eyrieConvertibleByQualityInstance[Attr[_], Param, A, B](
implicit F: Convertible.Aux[Attr, Param, A, B]
): Convertible.ByQuality.Aux[Attr[Param], A, B] =
new Convertible.ByQuality[Attr[Param], B] {
Expand Down
23 changes: 14 additions & 9 deletions core/src/main/scala/eyrie/instances/DescendantInstances.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import scala.Function.const

private[eyrie]
trait DescendantInstances {
implicit def eyrieSubdivisionBasedInstance[A, LA, RA, B](
implicit def eyrieDescendantBasedInstance[A, LA, RA, B](
implicit
A: Subdivision[A, LA, RA],
LA: Descendant[LA, B],
Expand All @@ -19,10 +19,18 @@ trait DescendantInstances {
def root: A => B =
A.subdivide(_).fold(LA.root, RA.root)
}

implicit def eyrieNonDescendantBasedInstance[A, LA, RA](
implicit
A: Subdivision[A, LA, RA],
LA: NonDescendant[LA],
RA: NonDescendant[RA]
): NonDescendant[A] =
eyrieDescendantBasedInstance[A, LA, RA, Nothing]
}

private[eyrie]
trait DescendantByInputInstances extends LowPriorityDescendantByInputInstances {
trait DescendantByInputInstances {
implicit def eyrieTrivialByInputInstance[A](
implicit A: TrivialDescendant[A]
): Descendant.ByInput.Aux[A, A] =
Expand All @@ -39,11 +47,8 @@ trait DescendantByInputInstances extends LowPriorityDescendantByInputInstances {
def root: A => A =
A.root
}
}

private[eyrie]
trait LowPriorityDescendantByInputInstances {
implicit def eyrieByInputInstance[A, B](
implicit def eyrieDescendantByInputInstance[A, B](
implicit A: Descendant[A, B]
): Descendant.ByInput.Aux[A, B] =
new Descendant.ByInput[A] {
Expand All @@ -58,7 +63,7 @@ trait LowPriorityDescendantByInputInstances {

private[eyrie]
trait PotentialDescendantInstances {
implicit def eyrieLeftSubdivisionBasedInstance[A, LA, RA, B](
implicit def eyrieLeftDescendantBasedInstance[A, LA, RA, B](
implicit
A: Subdivision[A, LA, RA],
LA: Descendant[LA, B],
Expand All @@ -70,7 +75,7 @@ trait PotentialDescendantInstances {
A.subdivide(_).fold(LA.root >>> (Some(_)), const(None))
}

implicit def eyrieRightSubdivisionBasedInstance[A, LA, RA, B](
implicit def eyrieRightDescendantBasedInstance[A, LA, RA, B](
implicit
A: Subdivision[A, LA, RA],
LA: NonDescendant[LA],
Expand All @@ -85,7 +90,7 @@ trait PotentialDescendantInstances {

private[eyrie]
trait PotentialDescendantByInputInstances {
implicit def eyrieByInputInstance[A, D](
implicit def eyriePotentialDescendantByInputInstance[A, D](
implicit A: PotentialDescendant[A, D]
): PotentialDescendant.ByInput.Aux[A, D] =
new PotentialDescendant.ByInput[A] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import eyrie.ops._

private[eyrie]
trait DiSuccessorInstances {
implicit def eyrieSubdivisionBasedInstance[A, LA, RA, LB, RB, C](
implicit def eyrieSuccessorBasedInstance[A, LA, RA, LB, RB, C](
implicit
A: Subdivision[A, LA, RA],
LA: Successor[LA, LB, C],
Expand All @@ -26,7 +26,7 @@ trait DiSuccessorInstances {

private[eyrie]
trait DiSuccessorByInputInstances {
implicit def eyrieByInputInstance[A, L, R, C](
implicit def eyrieDiSuccessorByInputInstance[A, L, R, C](
implicit A: DiSuccessor[A, L, R, C]
): DiSuccessor.ByInput.Aux[A, L, R, C] =
new DiSuccessor.ByInput[A] {
Expand All @@ -49,7 +49,7 @@ trait DiSuccessorByInputInstances {

private[eyrie]
trait DiPotentialSuccessorInstances {
implicit def eyrieSubdivisionBasedInstance[A, L, R, C](
implicit def eyriePotentialSuccessorBasedInstance[A, L, R, C](
implicit
A: Subdivision[A, L, R],
L: PotentialSuccessor[L, C],
Expand All @@ -68,7 +68,7 @@ trait DiPotentialSuccessorInstances {

private[eyrie]
trait DiPotentialSuccessorByInputInstances {
implicit def eyrieByInputInstance[A, L, R, C](
implicit def eyrieDiPotentialSuccessorByInputInstance[A, L, R, C](
implicit A: DiPotentialSuccessor[A, L, R, C]
): DiPotentialSuccessor.ByInput.Aux[A, L, R, C] =
new DiPotentialSuccessor.ByInput[A] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import eyrie.ops.Subdivision

private[eyrie]
trait SubdivisionByAttributeInstances {
implicit def eyrieByAttributeInstance[Attr[_], A, L, R](
implicit def eyrieSubdivisionByAttributeInstance[Attr[_], A, L, R](
implicit F: Subdivision.Aux[Attr, A, L, R]
): Subdivision.ByAttribute.Aux[Attr, A, L, R] =
new Subdivision.ByAttribute[Attr, A] {
Expand All @@ -21,7 +21,7 @@ trait SubdivisionByAttributeInstances {

private[eyrie]
trait SubdivisionByInputInstances {
implicit def eyrieByInputInstance[Attr[_], A, L, R](
implicit def eyrieSubdivisionByInputInstance[Attr[_], A, L, R](
implicit F: Subdivision.Aux[Attr, A, L, R]
): Subdivision.ByInput.Aux[Attr, A, L, R] =
new Subdivision.ByInput[A] {
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/scala/eyrie/instances/SuccessorInstances.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait SuccessorInstances {

private[eyrie]
trait SuccessorByInputInstances {
implicit def eyrieByInputInstance[A, B, C](implicit A: Successor[A, B, C]): Successor.ByInput.Aux[A, B, C] =
implicit def eyrieSuccessorByInputInstance[A, B, C](implicit A: Successor[A, B, C]): Successor.ByInput.Aux[A, B, C] =
new Successor.ByInput[A] {
override
type Prefix = B
Expand Down Expand Up @@ -76,7 +76,9 @@ trait PotentialSuccessorInstances {

private[eyrie]
trait PotentialSuccessorByInputInstances {
implicit def eyrieByInputInstance[A, C](implicit A: PotentialSuccessor[A, C]): PotentialSuccessor.ByInput.Aux[A, C] =
implicit def eyriePotentialSuccessorByInputInstance[A, C](
implicit A: PotentialSuccessor[A, C]
): PotentialSuccessor.ByInput.Aux[A, C] =
new PotentialSuccessor.ByInput[A] {
override
type Segment = C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,24 @@ import org.scalatest.junit.JUnitRunner
object PotentialDescendantSpec {
val nonEmpty: FilePath.NonEmpty[Sys] =
Internal.AbsoluteFile(Paths.get("a/b/c").toAbsolutePath)

val filePath: FilePath[Sys] =
Internal.RootDirectory(Paths.get("a/b/c").getRoot)
}

@RunWith(classOf[JUnitRunner])
class PotentialDescendantSpec extends FreeSpec {
import PotentialDescendantSpec._
import eyrie.syntax.potentialDescendant._

"File.Absolute" - {
"FilePath.Absolute" - {
"rootOption should be Option of RootDirectory" in {
nonEmpty.rootOption: Option[RootDirectory[Sys]]
}
}
"FilePath" - {
"rootOption should be Option of RootDirectory" in {
filePath.rootOption: Option[RootDirectory[Sys]]
}
}
}

0 comments on commit c00b469

Please sign in to comment.