Skip to content

Commit

Permalink
Changes for Scala 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jan 19, 2025
1 parent 16b777f commit 13d6448
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/core/anticipation+serpentine-core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import prepositional.*
import serpentine.*

package filesystemApi:
given [PlatformType: {Navigable, Radical}]
=> (Path on PlatformType) is GenericPath & SpecificPath as serpentinePath =
given serpentinePath: [PlatformType: {Navigable, Radical}]
=> (Path on PlatformType) is GenericPath & SpecificPath =
new GenericPath with SpecificPath:
type Self = Path on PlatformType
def pathText(path: Path on PlatformType): Text = path.text
Expand Down
18 changes: 9 additions & 9 deletions src/core/serpentine.Path.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ import vacuous.*
import scala.compiletime.*

object Path:
given [PathType <: Path] => PathType is Encodable in Text as encodable = _.text
given encodable: [PathType <: Path] => PathType is Encodable in Text = _.text

given [PlatformType: {Navigable, Radical}] => Decoder[Path on PlatformType] as decoder =
given decoder: [PlatformType: {Navigable, Radical}] => Decoder[Path on PlatformType] =
Path.parse(_)

given [PlatformType] => (Path on PlatformType) is Showable as showable = _.text
given [PlatformType] => (Path on PlatformType) is GenericPath as generic = _.text
given [PlatformType] => (Path on PlatformType) is Nominable as nominable = path =>
given showable: [PlatformType] => (Path on PlatformType) is Showable = _.text
given generic: [PlatformType] => (Path on PlatformType) is GenericPath = _.text
given nominable: [PlatformType] => (Path on PlatformType) is Nominable = path =>
path.textDescent.prim.or(path.textRoot)

given [PlatformType: {Navigable, Radical}] => Path on PlatformType is SpecificPath as specific =
given specific: [PlatformType: {Navigable, Radical}] => Path on PlatformType is SpecificPath =
_.decode[Path on PlatformType]

given Path is Communicable as communicable = path =>
given communicable: Path is Communicable = path =>
Message(path.textDescent.reverse.join(path.textRoot, path.separator, t""))

given [PlatformType: Navigable](using Tactic[PathError])
given addable: [PlatformType: Navigable] => Tactic[PathError]
=> (Path on PlatformType) is Addable by (Relative by PlatformType.Operand) into
(Path on PlatformType) as addable =
(Path on PlatformType) =
(left, right) =>
def recur(descent: List[Text], ascent: Int): Path on PlatformType =
if ascent > 0 then
Expand Down
4 changes: 2 additions & 2 deletions src/core/serpentine.PathAscent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import rudiments.*
import symbolism.*

object PathAscent:
given [ElementType](using Navigable by ElementType)
given [ElementType] => (Navigable by ElementType)
=> PathAscent is Divisible by ElementType into (Relative by ElementType) =
new Divisible:
type Self = PathAscent
Expand All @@ -49,6 +49,6 @@ case class PathAscent(ascent0: Int) extends Relative(ascent0, Nil, t"/"):
type Operand = Nothing

@targetName("parent")
infix def / (parent: ^.type): PathAscent = PathAscent(ascent + 1)
infix def / (parent: Serpentine.^.type): PathAscent = PathAscent(ascent + 1)

override def parent: PathAscent = PathAscent(ascent + 1)
10 changes: 4 additions & 6 deletions src/core/serpentine.Relative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ import vacuous.*
import scala.compiletime.*

object Relative:
given [RelativeType <: Relative](using navigable: Navigable)
=> RelativeType is Encodable in Text as encodable = relative =>
if relative.textDescent.isEmpty
then
given encodable: [RelativeType <: Relative] => (navigable: Navigable)
=> RelativeType is Encodable in Text = relative =>
if relative.textDescent.isEmpty then
if relative.ascent == 0 then navigable.selfText
else List.fill(relative.ascent)(navigable.parentElement).join(navigable.separator)
else
Expand All @@ -42,8 +41,7 @@ object Relative:
given [ElementType, RootType: Navigable by ElementType] => (Relative by ElementType) is Showable =
encodable.encode(_)

given [ElementType](using Navigable by ElementType)
=> Decoder[Relative by ElementType] as decoder =
given decoder: [ElementType] => (Navigable by ElementType) => Decoder[Relative by ElementType] =
parse(_)

def parse[ElementType](using navigable: Navigable by ElementType)(text: Text)
Expand Down

0 comments on commit 13d6448

Please sign in to comment.