diff --git a/src/core/serpentine.Path.scala b/src/core/serpentine.Path.scala index 7a5d3af..0ff96db 100644 --- a/src/core/serpentine.Path.scala +++ b/src/core/serpentine.Path.scala @@ -71,7 +71,7 @@ object Path: ElementType, PlatformType: {Navigable by ElementType, Radical from RootType}] (root0: RootType, elements: List[ElementType]) - : Path on PlatformType = + : Path on PlatformType = if elements.isEmpty then root0 else Path.from[PlatformType] (PlatformType.rootText(root0), @@ -81,7 +81,7 @@ object Path: private def from[PlatformType] (root0: Text, elements: List[Text], separator: Text, caseSensitivity: Case) - : Path on PlatformType = + : Path on PlatformType = new Path(root0, elements, separator, caseSensitivity): type Platform = PlatformType @@ -128,7 +128,7 @@ extends Pathlike: textDescent.prim.let(navigable.element(_)) def peer(using navigable: Platform is Navigable)(name: navigable.Operand) - : Path on Platform raises PathError = + : Path on Platform raises PathError = parent.let(_ / name).lest(PathError(PathError.Reason.RootParent)) def descent(using navigable: Platform is Navigable): List[navigable.Operand] = @@ -175,7 +175,7 @@ extends Pathlike: val right0 = right.textDescent.drop(-difference) def recur(left: List[Text], right: List[Text], size: Int, count: Int) - : Path on Platform = + : Path on Platform = if left.isEmpty then Path.from(textRoot, left0.drop(size - count), separator, caseSensitivity) else if left.head == right.head then recur(left.tail, right.tail, size + 1, count + 1) @@ -190,12 +190,12 @@ extends Pathlike: (textRoot, textDescent.drop(depth - count), separator, caseSensitivity) def relativeTo(right: Path on Platform)(using navigable: Platform is Navigable) - : Relative by navigable.Operand raises PathError = + : Relative by navigable.Operand raises PathError = if textRoot != right.textRoot then abort(PathError(PathError.Reason.DifferentRoots)) val common = conjunction(right).depth Relative(right.depth - common, textDescent.dropRight(common).map(navigable.element(_))) def resolve(text: Text)(using Platform is Navigable, Platform is Radical) - : Path on Platform raises PathError = + : Path on Platform raises PathError = safely(Path.parse(text)).or(safely(this + Relative.parse(text))).or: abort(PathError(PathError.Reason.InvalidRoot)) diff --git a/src/core/serpentine.Relative.scala b/src/core/serpentine.Relative.scala index b6539c9..0598165 100644 --- a/src/core/serpentine.Relative.scala +++ b/src/core/serpentine.Relative.scala @@ -45,7 +45,7 @@ object Relative: parse(_) def parse[ElementType](using navigable: Navigable by ElementType)(text: Text) - : Relative by ElementType = + : Relative by ElementType = def recur(start: Int, ascent: Int, elements: List[ElementType]): Relative by ElementType = if start >= text.length then Relative(ascent, elements) else @@ -62,11 +62,11 @@ object Relative: def apply[ElementType](using navigable: Navigable by ElementType) (ascent0: Int, descent0: List[ElementType]) - : Relative by ElementType = + : Relative by ElementType = Relative.from[ElementType](ascent0, descent0.map(navigable.makeElement(_)), navigable.separator) private def from[ElementType](ascent0: Int, descent0: List[Text], separator: Text) - : Relative by ElementType = + : Relative by ElementType = new Relative(ascent0, descent0, separator): type Operand = ElementType diff --git a/src/core/serpentine.Serpentine.scala b/src/core/serpentine.Serpentine.scala index 0624dbf..f7e7951 100644 --- a/src/core/serpentine.Serpentine.scala +++ b/src/core/serpentine.Serpentine.scala @@ -32,7 +32,7 @@ object Serpentine: object `/`: def unapply[PlatformType <: AnyRef & Matchable: {Navigable, Radical}, ElementType] (path: Path on PlatformType) - : Option[(Path on PlatformType, PlatformType.Operand)] = + : Option[(Path on PlatformType, PlatformType.Operand)] = path.textDescent match case Nil => None case head :: Nil => Some((PlatformType.root(path.textRoot), PlatformType.element(head)))