Skip to content

Commit

Permalink
WIP: scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Oct 4, 2023
1 parent 7d9e6b1 commit 5d245eb
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
9 changes: 6 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ ThisBuild / versionScheme := Some("early-semver")

Global / onChangedBuildSource := ReloadOnSourceChanges

ThisBuild / scalaVersion := "2.13.11"
ThisBuild / crossScalaVersions := Seq("2.13.11")
ThisBuild / scalaVersion := "3.3.1"
ThisBuild / crossScalaVersions := Seq("3.3.1")

// For coursier's "latest.integration"
ThisBuild / dynverSeparator := "-"
Expand Down Expand Up @@ -156,7 +156,10 @@ lazy val lsp = module("lsp")
"io.circe" %% "circe-core" % "0.14.6",
"org.http4s" %% "http4s-ember-client" % "0.23.23",
"org.http4s" %% "http4s-ember-server" % "0.23.23" % Test,
"io.get-coursier" %% "coursier" % "2.1.7",
("io.get-coursier" % "coursier" % "2.1.7")
.cross(CrossVersion.for3Use2_13)
.exclude("org.scala-lang.modules", "scala-collection-compat_2.13")
.exclude("com.github.plokhotnyuk.jsoniter-scala", "jsoniter-scala-core_2.13"),
"org.typelevel" %% "cats-tagless-core" % "0.15.0",
),
buildInfoPackage := "playground.lsp.buildinfo",
Expand Down
3 changes: 2 additions & 1 deletion modules/ast/src/main/scala/playground/smithyql/AST.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ object QualifiedIdentifier {

implicit val show: Show[QualifiedIdentifier] = Show.fromToString

implicit val ord: Order[QualifiedIdentifier] = Order.by(unapply(_).get)
// todo: dotty claims infinite loop
implicit val ord: Order[QualifiedIdentifier] = Order.by(unapply(_))

}

Expand Down
16 changes: 3 additions & 13 deletions modules/core/src/main/scala/playground/DynamicServiceProxy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class DynamicServiceProxy[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]](
): FunctorInterpreter[Op, F] = {
val grp = serviceStatic.endpoints.groupBy(_.id).fmap(_.head)

type Proxy[I, E, O, SE, EO] = I => F[O]

def makeProxy[A, B](
schemaIn: Schema[A],
schemaOut: Schema[B],
Expand All @@ -39,7 +37,7 @@ class DynamicServiceProxy[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]](
}

val endpointMapping =
new smithy4s.kinds.PolyFunction5[Endpoint[Op, *, *, *, *, *], Proxy] {
new service.FunctorEndpointCompiler[F] {
private val trans = serviceStatic.toPolyFunction(interp)

private def applyWithStatic[I, E, O, SI, SO, STI, STE, STO, STSI, STSO](
Expand Down Expand Up @@ -77,16 +75,8 @@ class DynamicServiceProxy[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]](
endpoint: Endpoint[Op, I, E, O, SI, SO]
): I => F[O] = applyWithStatic(endpoint, grp(endpoint.id))
}
.precomputeBy(service.endpoints, _.name)

new FunctorInterpreter[Op, F] {
def apply[I, E, O, SI, SO](
op: Op[I, E, O, SI, SO]
): F[O] = {
val (input, endpoint) = service.endpoint(op)
endpointMapping(endpoint)(input)
}
}

service.functorInterpreter(endpointMapping)
}

private final implicit class PolyFunction5Ops[F[_, _, _, _, _], G[_, _, _, _, _]](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private class ServiceCompiler[Alg[_[_, _, _, _, _]]](
) extends OperationCompiler[IorNel[CompilationError, *]] {

private def compileEndpoint[In, Err, Out](
e: Endpoint[service.Operation, In, Err, Out, _, _]
e: Endpoint[service.Operation, In, Err, Out, SE, _]
): QueryCompiler[CompiledInput] = {
val inputCompiler = e.input.compile(QueryCompilerVisitor.full)
val outputEncoder = NodeEncoder.derive(e.output)
Expand All @@ -165,7 +165,7 @@ private class ServiceCompiler[Alg[_[_, _, _, _, _]]](
type E = Err
type O = Out

val op: _Op[_, Err, Out, _, _] = e.wrap(compiled)
val op: _Op[_I, E, O, SE, SO] = e.wrap(compiled)
val writeOutput: NodeEncoder[Out] = outputEncoder
val writeError: Option[NodeEncoder[Err]] = errorEncoder
val catchError: Throwable => Option[Err] = e.Error.unapply(_).map(_._2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ object AddDynamicRefinements extends (Schema ~> Schema) {

def apply[A](
schema: Schema[A]
): Schema[A] =
schema match {
): Schema[A] = ???
/* schema match {
case PrimitiveSchema(_, _, tag) =>
tag match {
case PString => schema.reifyHint[api.Length].reifyHint[api.Pattern]
Expand All @@ -76,6 +76,6 @@ object AddDynamicRefinements extends (Schema ~> Schema) {
case s: StructSchema[_] => s
case l: LazySchema[_] => l
case u: UnionSchema[_] => u
}
} */

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ object StdlibRuntime {

val random: Random[F] =
new playground.std.Random[F] {

def nextUUID(
): F[NextUUIDOutput] = UUIDGen[F].randomUUID.map(_.toString).map(NextUUIDOutput(_))
): F[NextUUIDOutput] = UUIDGen[F]
.randomUUID
.map(_.toString)
.map(playground.std.UUID(_))
.map(NextUUIDOutput(_))

}

val clock: Clock[F] =
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml"
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.3")

addSbtPlugin("com.disneystreaming.smithy4s" % "smithy4s-sbt-codegen" % "0.17.11")
addSbtPlugin("com.disneystreaming.smithy4s" % "smithy4s-sbt-codegen" % "0.17.19")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.1")
Expand Down
2 changes: 1 addition & 1 deletion smithy-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"imports": ["modules/core/src/test/smithy"],
"mavenDependencies": [
"com.disneystreaming.alloy:alloy-core:0.2.7",
"com.disneystreaming.smithy4s:smithy4s-protocol:0.17.6",
"com.disneystreaming.smithy4s:smithy4s-protocol:0.17.19",
"software.amazon.smithy:smithy-aws-traits:1.34.0"
]
}

0 comments on commit 5d245eb

Please sign in to comment.