From 8d7bf602c19fc319ef90024928a48d593d35b750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Wed, 2 Nov 2022 12:48:43 +0100 Subject: [PATCH 01/21] Move Op from parameter to member in smithy4s.Service Similarly to what happened with `cats.Parallel`, the Operation type of `smithy4s.Service` can be moved from type-parameter to type-member, which helps implicit search. --- modules/aws/src/smithy4s/aws/AwsClient.scala | 28 ++++----- .../aws/internals/AwsJsonRPCInterpreter.scala | 2 +- .../src/smithy4s/codegen/Renderer.scala | 6 +- modules/core/src/smithy4s/Service.scala | 37 +++++++----- modules/core/src/smithy4s/http/package.scala | 24 +++++--- modules/core/src/smithy4s/package.scala | 6 +- .../smithy4s/dynamic/DynamicSchemaIndex.scala | 3 +- .../dynamic/internals/DynamicService.scala | 3 +- .../src/smithy4s/dynamic/FieldsSpec.scala | 4 +- .../http4s/SimpleProtocolBuilder.scala | 58 +++++++++---------- .../http4s/SmithyHttp4sReverseRouter.scala | 2 +- .../smithy4s/http4s/SmithyHttp4sRouter.scala | 2 +- .../http4s/src/smithy4s/http4s/package.scala | 8 +-- .../src/smithy4s/tests/DummyService.scala | 9 ++- .../src/smithy4s/tests/JsonProtocolF.scala | 23 ++++---- .../tests/src/smithy4s/tests/PizzaSpec.scala | 6 +- 16 files changed, 121 insertions(+), 100 deletions(-) diff --git a/modules/aws/src/smithy4s/aws/AwsClient.scala b/modules/aws/src/smithy4s/aws/AwsClient.scala index 2aa960732..009eab162 100644 --- a/modules/aws/src/smithy4s/aws/AwsClient.scala +++ b/modules/aws/src/smithy4s/aws/AwsClient.scala @@ -25,15 +25,15 @@ import smithy4s.kinds.PolyFunction5 object AwsClient { - def apply[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _], F[_]: MonadThrow]( - service: smithy4s.Service[Alg, Op], + def apply[Alg[_[_, _, _, _, _]], F[_]: MonadThrow]( + service: smithy4s.Service[Alg], awsEnv: AwsEnvironment[F] ): Resource[F, AwsClient[Alg, F]] = - prepare(service).map(_.interpret(awsEnv)).liftTo[Resource[F, *]] + prepare(service).map(_.build(awsEnv)).liftTo[Resource[F, *]] - def prepare[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( - service: smithy4s.Service[Alg, Op] - ): Either[Throwable, AWSInterpreterBuilder[Alg, Op]] = + def prepare[Alg[_[_, _, _, _, _]]]( + service: smithy4s.Service[Alg] + ): Either[Throwable, AWSInterpreterBuilder[Alg]] = for { awsService <- service.hints .get(_root_.aws.api.Service) @@ -50,18 +50,18 @@ object AwsClient { ) } yield new AWSInterpreterBuilder(awsProtocol, service, endpointPrefix) - final class AWSInterpreterBuilder[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( + final class AWSInterpreterBuilder[Alg[_[_, _, _, _, _]]]( awsProtocol: AwsProtocol, - service: smithy4s.Service[Alg, Op], + service: smithy4s.Service[Alg], endpointPrefix: String ) { - def build[F[_]: MonadThrow]( + private def interpreter[F[_]: MonadThrow]( awsEnv: AwsEnvironment[F] - ): PolyFunction5[Op, AwsCall[F, *, *, *, *, *]] = + ): PolyFunction5[service.Operation, AwsCall[F, *, *, *, *, *]] = awsProtocol match { case AwsProtocol.AWS_JSON_1_0(_) => - new AwsJsonRPCInterpreter[Alg, Op, F]( + new AwsJsonRPCInterpreter[Alg, service.Operation, F]( service, endpointPrefix, awsEnv, @@ -69,7 +69,7 @@ object AwsClient { ) case AwsProtocol.AWS_JSON_1_1(_) => - new AwsJsonRPCInterpreter[Alg, Op, F]( + new AwsJsonRPCInterpreter[Alg, service.Operation, F]( service, endpointPrefix, awsEnv, @@ -77,9 +77,9 @@ object AwsClient { ) } - def interpret[F[_]: MonadThrow]( + def build[F[_]: MonadThrow]( awsEnv: AwsEnvironment[F] - ): AwsClient[Alg, F] = service.fromPolyFunction(build(awsEnv)) + ): AwsClient[Alg, F] = service.fromPolyFunction(interpreter(awsEnv)) } private def initError(msg: String): Throwable = InitialisationError(msg) case class InitialisationError(msg: String) extends Throwable(msg) diff --git a/modules/aws/src/smithy4s/aws/internals/AwsJsonRPCInterpreter.scala b/modules/aws/src/smithy4s/aws/internals/AwsJsonRPCInterpreter.scala index 31d085834..cdb7bae06 100644 --- a/modules/aws/src/smithy4s/aws/internals/AwsJsonRPCInterpreter.scala +++ b/modules/aws/src/smithy4s/aws/internals/AwsJsonRPCInterpreter.scala @@ -26,7 +26,7 @@ import smithy4s.kinds._ * An interpreter for unary operations in the AWS_JSON_1.0/AWS_JSON_1.1 protocol */ private[aws] class AwsJsonRPCInterpreter[Alg[_[_, _, _, _, _]], Op[_,_,_,_,_], F[_]]( - service: smithy4s.Service[Alg, Op], + service: smithy4s.Service.Aux[Alg, Op], endpointPrefix: String, awsEnv: AwsEnvironment[F], contentType: String diff --git a/modules/codegen/src/smithy4s/codegen/Renderer.scala b/modules/codegen/src/smithy4s/codegen/Renderer.scala index 17a4a982b..504daad60 100644 --- a/modules/codegen/src/smithy4s/codegen/Renderer.scala +++ b/modules/codegen/src/smithy4s/codegen/Renderer.scala @@ -168,10 +168,10 @@ private[codegen] class Renderer(compilationUnit: CompilationUnit) { self => lines( line"type ${NameDef(name)}[F[_]] = $FunctorAlgebra_[$nameGen, F]", block( - line"object ${NameRef(name)} extends $Service_.Provider[$nameGen, ${name}Operation]" + line"object ${NameRef(name)} extends $Service_.Provider[$nameGen]" )( line"def apply[F[_]](implicit F: ${NameRef(name)}[F]): F.type = F", - line"def service: $Service_[$nameGen, ${name}Operation] = $nameGen", + line"def service: $Service_[$nameGen] = $nameGen", line"val id: $ShapeId_ = service.id" ) ) @@ -205,7 +205,7 @@ private[codegen] class Renderer(compilationUnit: CompilationUnit) { self => newline, obj( genNameRef, - ext = line"$Service_[$genNameRef, $opTraitNameRef]" + ext = line"$Service_.Mixin[$genNameRef, $opTraitNameRef]" )( newline, line"def apply[F[_]](implicit F: $FunctorAlgebra_[$genNameRef, F]): F.type = F", diff --git a/modules/core/src/smithy4s/Service.scala b/modules/core/src/smithy4s/Service.scala index 3b3c53eb2..1ede1ea18 100644 --- a/modules/core/src/smithy4s/Service.scala +++ b/modules/core/src/smithy4s/Service.scala @@ -34,33 +34,44 @@ import kinds._ * around makes it drastically easier to implement logic generically, without involving * metaprogramming. */ -trait Service[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]] extends FunctorK5[Alg] with Service.Provider[Alg, Op] { - implicit val serviceInstance: Service[Alg, Op] = this - val service = this +trait Service[Alg[_[_, _, _, _, _]]] extends FunctorK5[Alg] with Service.Provider[Alg] { + type Operation[E, I, O, SI, SO] - def endpoints: List[Endpoint[Op, _, _, _, _, _]] - def endpoint[I, E, O, SI, SO](op: Op[I, E, O, SI, SO]): (I, Endpoint[Op, I, E, O, SI, SO]) + val service: Service[Alg] = this + def endpoints: List[Endpoint[Operation, _, _, _, _, _]] + def endpoint[I, E, O, SI, SO](op: Operation[I, E, O, SI, SO]): (I, Endpoint[Operation, I, E, O, SI, SO]) def version: String def hints: Hints - def reified: Alg[Op] - def fromPolyFunction[P[_, _, _, _, _]](function: PolyFunction5[Op, P]): Alg[P] - def toPolyFunction[P[_, _, _, _, _]](algebra: Alg[P]): PolyFunction5[Op, P] + def reified: Alg[Operation] + def fromPolyFunction[P[_, _, _, _, _]](function: PolyFunction5[Operation, P]): Alg[P] + def toPolyFunction[P[_, _, _, _, _]](algebra: Alg[P]): PolyFunction5[Operation, P] - final val opToEndpoint : PolyFunction5[Op, Endpoint[Op, *, *, *, *, *]] = new PolyFunction5[Op, Endpoint[Op, *, *, *, *, *]]{ - def apply[I, E, O, SI, SO](op: Op[I,E,O,SI,SO]): Endpoint[Op,I,E,O,SI,SO] = endpoint(op)._2 + final val opToEndpoint : PolyFunction5[Operation, Endpoint[Operation, *, *, *, *, *]] = new PolyFunction5[Operation, Endpoint[Operation, *, *, *, *, *]]{ + def apply[I, E, O, SI, SO](op: Operation[I,E,O,SI,SO]): Endpoint[Operation,I,E,O,SI,SO] = endpoint(op)._2 } } object Service { - trait Provider[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]] extends HasId { - def service: Service[Alg, Op] + + def apply[Alg[_[_, _, _, _, _]]](implicit ev: Service[Alg]): ev.type = ev + + type Aux[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]] = Service[Alg]{ type Operation[I, E, O, SI, SO] = Op[I, E, O, SI, SO] } + + trait Provider[Alg[_[_, _, _, _, _]]] extends HasId { + def service: Service[Alg] + } + + trait Mixin[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]] extends Service[Alg]{ + implicit val serviceInstance: Service[Alg] = this + type Operation[I, E, O, SI, SO] = Op[I, E, O, SI, SO] } /** * A Service the algebra of which is a PolyFunction */ - trait Reflective[Op[_, _, _, _, _]] extends Service[PolyFunction5.From[Op]#Algebra, Op] { + trait Reflective[Op[_, _, _, _, _]] extends Service[PolyFunction5.From[Op]#Algebra] { + type Operation[I, E, O, SI, SO] = Op[I, E, O, SI, SO] final def reified: PolyFunction5[Op, Op] = PolyFunction5.identity final def fromPolyFunction[P[_, _, _, _, _]](function: PolyFunction5[Op, P]): PolyFunction5[Op, P] = function final def toPolyFunction[P[_, _, _, _, _]](algebra: PolyFunction5[Op, P]): PolyFunction5[Op, P] = algebra diff --git a/modules/core/src/smithy4s/http/package.scala b/modules/core/src/smithy4s/http/package.scala index 001b71271..94ccb1254 100644 --- a/modules/core/src/smithy4s/http/package.scala +++ b/modules/core/src/smithy4s/http/package.scala @@ -21,14 +21,18 @@ package object http { type PathParams = Map[String, String] type HttpMediaType = HttpMediaType.Type - final def httpMatch[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( - serviceProvider: Service.Provider[Alg, Op], + final def httpMatch[Alg[_[_, _, _, _, _]]]( + service: Service[Alg], method: http.HttpMethod, path: String ): Option[ - (Endpoint[Op, _, _, _, _, _], http.HttpEndpoint[_], Map[String, String]) + ( + Endpoint[service.Operation, _, _, _, _, _], + http.HttpEndpoint[_], + Map[String, String] + ) ] = httpMatch( - serviceProvider, + service, method, pathSegments = matchPath.make(path).toVector ) @@ -37,14 +41,18 @@ package object http { * Returns the first http endpoint that matches both a method and path, as well as the map * of extracted segment values. */ - final def httpMatch[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( - serviceProvider: Service.Provider[Alg, Op], + final def httpMatch[Alg[_[_, _, _, _, _]]]( + service: Service[Alg], method: http.HttpMethod, pathSegments: Vector[String] ): Option[ - (Endpoint[Op, _, _, _, _, _], http.HttpEndpoint[_], Map[String, String]) + ( + Endpoint[service.Operation, _, _, _, _, _], + http.HttpEndpoint[_], + Map[String, String] + ) ] = { - serviceProvider.service.endpoints.iterator + service.endpoints.iterator .map { case endpoint @ http.HttpEndpoint(httpEndpoint) if httpEndpoint.method == method => diff --git a/modules/core/src/smithy4s/package.scala b/modules/core/src/smithy4s/package.scala index 108c4056c..be672a179 100644 --- a/modules/core/src/smithy4s/package.scala +++ b/modules/core/src/smithy4s/package.scala @@ -25,13 +25,13 @@ package object smithy4s { val errorTypeHeader = "X-Error-Type" - def checkProtocol[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( - service: Service[Alg, Op], + def checkProtocol[Alg[_[_, _, _, _, _]]]( + service: Service[Alg], protocolTag: ShapeTag[_] ): Either[UnsupportedProtocolError, Unit] = service.hints .get(protocolTag) - .toRight(UnsupportedProtocolError(service, protocolTag.id)) + .toRight(UnsupportedProtocolError(service.id, protocolTag.id)) .map(_ => ()) } diff --git a/modules/dynamic/src/smithy4s/dynamic/DynamicSchemaIndex.scala b/modules/dynamic/src/smithy4s/dynamic/DynamicSchemaIndex.scala index a8ee2250e..995aa109f 100644 --- a/modules/dynamic/src/smithy4s/dynamic/DynamicSchemaIndex.scala +++ b/modules/dynamic/src/smithy4s/dynamic/DynamicSchemaIndex.scala @@ -53,9 +53,8 @@ object DynamicSchemaIndex extends DynamicSchemaIndexPlatform { */ trait ServiceWrapper { type Alg[P[_, _, _, _, _]] - type Op[I, E, O, SI, SO] - def service: Service[Alg, Op] + def service: Service[Alg] } } diff --git a/modules/dynamic/src/smithy4s/dynamic/internals/DynamicService.scala b/modules/dynamic/src/smithy4s/dynamic/internals/DynamicService.scala index 23e5a097f..c8a3586ae 100644 --- a/modules/dynamic/src/smithy4s/dynamic/internals/DynamicService.scala +++ b/modules/dynamic/src/smithy4s/dynamic/internals/DynamicService.scala @@ -29,8 +29,7 @@ private[internals] case class DynamicService( with DynamicSchemaIndex.ServiceWrapper { type Alg[P[_, _, _, _, _]] = PolyFunction5.From[DynamicOp]#Algebra[P] - type Op[I, E, O, SI, SO] = DynamicOp[I, E, O, SI, SO] - override val service: Service[Alg, Op] = this + override val service: Service[Alg] = this private lazy val endpointMap : Map[ShapeId, Endpoint[DynamicOp, _, _, _, _, _]] = diff --git a/modules/dynamic/test/src/smithy4s/dynamic/FieldsSpec.scala b/modules/dynamic/test/src/smithy4s/dynamic/FieldsSpec.scala index f03a1855d..71c435662 100644 --- a/modules/dynamic/test/src/smithy4s/dynamic/FieldsSpec.scala +++ b/modules/dynamic/test/src/smithy4s/dynamic/FieldsSpec.scala @@ -83,8 +83,8 @@ class FieldsSpec() extends munit.FunSuite { } - def toFieldNames[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( - svc: Service[Alg, Op] + def toFieldNames[Alg[_[_, _, _, _, _]]]( + svc: Service[Alg] ): List[String] = svc.endpoints.flatMap { endpoint => endpoint.input.compile(GetFieldNames)() ++ diff --git a/modules/http4s/src/smithy4s/http4s/SimpleProtocolBuilder.scala b/modules/http4s/src/smithy4s/http4s/SimpleProtocolBuilder.scala index 7b8fa85ee..b6507c057 100644 --- a/modules/http4s/src/smithy4s/http4s/SimpleProtocolBuilder.scala +++ b/modules/http4s/src/smithy4s/http4s/SimpleProtocolBuilder.scala @@ -35,31 +35,29 @@ abstract class SimpleProtocolBuilder[P](val codecs: CodecAPI)(implicit protocolTag: ShapeTag[P] ) { - def apply[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( - serviceProvider: smithy4s.Service.Provider[Alg, Op] - ): ServiceBuilder[Alg, Op] = new ServiceBuilder(serviceProvider.service) + def apply[Alg[_[_, _, _, _, _]]]( + serviceProvider: smithy4s.Service.Provider[Alg] + ): ServiceBuilder[Alg] = new ServiceBuilder(serviceProvider.service) - def routes[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _], F[_]]( + def routes[Alg[_[_, _, _, _, _]], F[_]]( impl: FunctorAlgebra[Alg, F] )(implicit - serviceProvider: smithy4s.Service.Provider[Alg, Op], + service: smithy4s.Service[Alg], F: EffectCompat[F] - ): RouterBuilder[Alg, Op, F] = { - val service = serviceProvider.service - new RouterBuilder[Alg, Op, F]( + ): RouterBuilder[Alg, F] = { + new RouterBuilder[Alg, F]( service, - service.toPolyFunction[Kind1[F]#toKind5](impl), + impl, PartialFunction.empty ) } class ServiceBuilder[ - Alg[_[_, _, _, _, _]], - Op[_, _, _, _, _] - ] private[http4s] (val service: smithy4s.Service[Alg, Op]) { self => + Alg[_[_, _, _, _, _]] + ] private[http4s] (val service: smithy4s.Service[Alg]) { self => def client[F[_]: EffectCompat](client: Client[F]) = - new ClientBuilder[Alg, Op, F](client, service) + new ClientBuilder[Alg, F](client, service) @deprecated( "Use the ClientBuilder instead, client(client).uri(baseuri).use" ) @@ -80,25 +78,26 @@ abstract class SimpleProtocolBuilder[P](val codecs: CodecAPI)(implicit def routes[F[_]: EffectCompat]( impl: FunctorAlgebra[Alg, F] - ): RouterBuilder[Alg, Op, F] = - new RouterBuilder[Alg, Op, F]( + ): RouterBuilder[Alg, F] = + new RouterBuilder[Alg, F]( service, - service.toPolyFunction[Kind1[F]#toKind5](impl), + impl, PartialFunction.empty ) } - class ClientBuilder[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _], F[ - _ - ]: EffectCompat] private[http4s] ( + class ClientBuilder[ + Alg[_[_, _, _, _, _]], + F[_]: EffectCompat + ] private[http4s] ( client: Client[F], - val service: smithy4s.Service[Alg, Op], + val service: smithy4s.Service[Alg], uri: Uri = uri"http://localhost:8080" ) { - def uri(uri: Uri): ClientBuilder[Alg, Op, F] = - new ClientBuilder[Alg, Op, F](this.client, this.service, uri) + def uri(uri: Uri): ClientBuilder[Alg, F] = + new ClientBuilder[Alg, F](this.client, this.service, uri) def resource: Resource[F, FunctorAlgebra[Alg, F]] = use.leftWiden[Throwable].liftTo[Resource[F, *]] @@ -106,7 +105,7 @@ abstract class SimpleProtocolBuilder[P](val codecs: CodecAPI)(implicit def use: Either[UnsupportedProtocolError, FunctorAlgebra[Alg, F]] = { checkProtocol(service, protocolTag) .as( - new SmithyHttp4sReverseRouter[Alg, Op, F]( + new SmithyHttp4sReverseRouter[Alg, service.Operation, F]( uri, service, client, @@ -120,11 +119,10 @@ abstract class SimpleProtocolBuilder[P](val codecs: CodecAPI)(implicit class RouterBuilder[ Alg[_[_, _, _, _, _]], - Op[_, _, _, _, _], F[_] ] private[http4s] ( - service: smithy4s.Service[Alg, Op], - impl: FunctorInterpreter[Op, F], + service: smithy4s.Service[Alg], + impl: FunctorAlgebra[Alg, F], errorTransformation: PartialFunction[Throwable, F[Throwable]] )(implicit F: EffectCompat[F]) { @@ -133,19 +131,19 @@ abstract class SimpleProtocolBuilder[P](val codecs: CodecAPI)(implicit def mapErrors( fe: PartialFunction[Throwable, Throwable] - ): RouterBuilder[Alg, Op, F] = + ): RouterBuilder[Alg, F] = new RouterBuilder(service, impl, fe andThen (e => F.pure(e))) def flatMapErrors( fe: PartialFunction[Throwable, F[Throwable]] - ): RouterBuilder[Alg, Op, F] = + ): RouterBuilder[Alg, F] = new RouterBuilder(service, impl, fe) def make: Either[UnsupportedProtocolError, HttpRoutes[F]] = checkProtocol(service, protocolTag).as { - new SmithyHttp4sRouter[Alg, Op, F]( + new SmithyHttp4sRouter[Alg, service.Operation, F]( service, - impl, + service.toPolyFunction[Kind1[F]#toKind5](impl), errorTransformation, entityCompiler ).routes diff --git a/modules/http4s/src/smithy4s/http4s/SmithyHttp4sReverseRouter.scala b/modules/http4s/src/smithy4s/http4s/SmithyHttp4sReverseRouter.scala index 3c2c27ddb..aec32919d 100644 --- a/modules/http4s/src/smithy4s/http4s/SmithyHttp4sReverseRouter.scala +++ b/modules/http4s/src/smithy4s/http4s/SmithyHttp4sReverseRouter.scala @@ -25,7 +25,7 @@ import smithy4s.http4s.internals.SmithyHttp4sClientEndpoint // format: off class SmithyHttp4sReverseRouter[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _], F[_]]( baseUri: Uri, - service: smithy4s.Service[Alg, Op], + service: smithy4s.Service.Aux[Alg, Op], client: Client[F], entityCompiler: EntityCompiler[F] )(implicit effect: EffectCompat[F]) diff --git a/modules/http4s/src/smithy4s/http4s/SmithyHttp4sRouter.scala b/modules/http4s/src/smithy4s/http4s/SmithyHttp4sRouter.scala index 94c445670..749a70e54 100644 --- a/modules/http4s/src/smithy4s/http4s/SmithyHttp4sRouter.scala +++ b/modules/http4s/src/smithy4s/http4s/SmithyHttp4sRouter.scala @@ -26,7 +26,7 @@ import smithy4s.kinds._ // format: off class SmithyHttp4sRouter[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _], F[_]]( - service: smithy4s.Service[Alg, Op], + service: smithy4s.Service.Aux[Alg, Op], impl: FunctorInterpreter[Op, F], errorTransformation: PartialFunction[Throwable, F[Throwable]], entityCompiler: EntityCompiler[F] diff --git a/modules/http4s/src/smithy4s/http4s/package.scala b/modules/http4s/src/smithy4s/http4s/package.scala index bfd8d9eba..5968e6a60 100644 --- a/modules/http4s/src/smithy4s/http4s/package.scala +++ b/modules/http4s/src/smithy4s/http4s/package.scala @@ -26,12 +26,12 @@ import smithy4s.http.{HttpMethod => SmithyMethod} package object http4s extends Compat.Package { - implicit final class ServiceOps[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( - private[this] val serviceProvider: smithy4s.Service.Provider[Alg, Op] + implicit final class ServiceOps[Alg[_[_, _, _, _, _]]]( + private[this] val serviceProvider: smithy4s.Service.Provider[Alg] ) { - def simpleRestJson: SimpleRestJsonBuilder.ServiceBuilder[Alg, Op] = - SimpleRestJsonBuilder(serviceProvider.service) + def simpleRestJson: SimpleRestJsonBuilder.ServiceBuilder[Alg] = + SimpleRestJsonBuilder(serviceProvider) } diff --git a/modules/test-utils/src/smithy4s/tests/DummyService.scala b/modules/test-utils/src/smithy4s/tests/DummyService.scala index 0d7aa969f..95d524d7c 100644 --- a/modules/test-utils/src/smithy4s/tests/DummyService.scala +++ b/modules/test-utils/src/smithy4s/tests/DummyService.scala @@ -25,13 +25,16 @@ object DummyService { def apply[F[_]]: PartiallyApplied[F] = new PartiallyApplied[F] class PartiallyApplied[F[_]] { - def create[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]](implicit - service: Service[Alg, Op], + def create[Alg[_[_, _, _, _, _]]](implicit + service: Service[Alg], F: Applicative[F] ): FunctorAlgebra[Alg, F] = { + type Op[I, E, O, SI, SO] = service.Operation[I, E, O, SI, SO] service.fromPolyFunction[Kind1[F]#toKind5] { service.opToEndpoint.andThen[Kind1[F]#toKind5]( - new PolyFunction5[Endpoint[Op, *, *, *, *, *], Kind1[F]#toKind5] { + new PolyFunction5[Endpoint[Op, *, *, *, *, *], Kind1[ + F + ]#toKind5] { def apply[I, E, O, SI, SO]( ep: Endpoint[Op, I, E, O, SI, SO] ): F[O] = diff --git a/modules/test-utils/src/smithy4s/tests/JsonProtocolF.scala b/modules/test-utils/src/smithy4s/tests/JsonProtocolF.scala index c5667eef9..78096d71f 100644 --- a/modules/test-utils/src/smithy4s/tests/JsonProtocolF.scala +++ b/modules/test-utils/src/smithy4s/tests/JsonProtocolF.scala @@ -31,19 +31,21 @@ import smithy4s.kinds._ */ class JsonProtocolF[F[_]](implicit F: MonadThrow[F]) { - def dummy[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( - service: Service.Provider[Alg, Op] + def dummy[Alg[_[_, _, _, _, _]]]( + service: Service.Provider[Alg] ): Document => F[Document] = { - implicit val S: Service[Alg, Op] = service.service - toJsonF[Alg, Op](DummyService[F].create[Alg, Op]) + implicit val S: Service[Alg] = service.service + toJsonF[Alg, S.Operation](DummyService[F].create[Alg]) } - def redactingProxy[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( + def redactingProxy[Alg[_[_, _, _, _, _]]]( jsonF: Document => F[Document], - service: Service.Provider[Alg, Op] + service: Service.Provider[Alg] ): Document => F[Document] = { - implicit val S: Service[Alg, Op] = service.service - toJsonF[Alg, Op](fromJsonF[Alg, Op](jsonF)) andThen (_.map(redact)) + implicit val S: Service[Alg] = service.service + toJsonF[Alg, S.Operation]( + fromJsonF[Alg, S.Operation](jsonF) + ) andThen (_.map(redact)) } def redact(document: Document): Document = document match { @@ -55,7 +57,8 @@ class JsonProtocolF[F[_]](implicit F: MonadThrow[F]) { def fromJsonF[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( jsonF: Document => F[Document] - )(implicit S: Service[Alg, Op]): FunctorAlgebra[Alg, F] = { + )(implicit S: Service[Alg]): FunctorAlgebra[Alg, F] = { + type Op[I, E, O, SI, SO] = S.Operation[I, E, O, SI, SO] val kleisliCache = fromLowLevel(jsonF).unsafeCacheBy( S.endpoints.map(Kind5.existential(_)), @@ -72,7 +75,7 @@ class JsonProtocolF[F[_]](implicit F: MonadThrow[F]) { def toJsonF[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( alg: FunctorAlgebra[Alg, F] - )(implicit S: Service[Alg, Op]): Document => F[Document] = { + )(implicit S: Service[Alg]): Document => F[Document] = { val transformation = S.toPolyFunction[Kind1[F]#toKind5](alg) val jsonEndpoints = S.endpoints.map(ep => ep.name -> toLowLevel(transformation, ep)).toMap diff --git a/modules/tests/src/smithy4s/tests/PizzaSpec.scala b/modules/tests/src/smithy4s/tests/PizzaSpec.scala index 2ba124c99..6f63ebaee 100644 --- a/modules/tests/src/smithy4s/tests/PizzaSpec.scala +++ b/modules/tests/src/smithy4s/tests/PizzaSpec.scala @@ -437,7 +437,7 @@ abstract class PizzaSpec pureTest("Happy path: httpMatch") { val matchResult = smithy4s.http .httpMatch( - PizzaAdminService, + PizzaAdminService.service, smithy4s.http.HttpMethod.POST, Vector("restaurant", "foo", "menu", "item") ) @@ -453,7 +453,7 @@ abstract class PizzaSpec pureTest("Negative: http no match (bad path)") { val matchResult = smithy4s.http.httpMatch( - PizzaAdminService, + PizzaAdminService.service, smithy4s.http.HttpMethod.POST, Vector("restaurants", "foo", "menu", "item") ) @@ -462,7 +462,7 @@ abstract class PizzaSpec pureTest("Negative: http no match (bad method)") { val matchResult = smithy4s.http.httpMatch( - PizzaAdminService, + PizzaAdminService.service, smithy4s.http.HttpMethod.PATCH, Vector("restaurant", "foo", "menu", "item") ) From 732c66f77d14472d6bbb9ae9d9a5314531354a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Wed, 2 Nov 2022 15:48:13 +0100 Subject: [PATCH 02/21] Fix compliance tests --- .../ClientHttpComplianceTestCase.scala | 12 ++++---- .../ServerHttpComplianceTestCase.scala | 22 +++++++------- .../WeaverComplianceTest.scala | 30 +++++++------------ 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala b/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala index ae670f23d..d842bb6f5 100644 --- a/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala +++ b/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala @@ -47,18 +47,18 @@ import org.http4s.Header abstract class ClientHttpComplianceTestCase[ P, - Alg[_[_, _, _, _, _]], - Op[_, _, _, _, _] + Alg[_[_, _, _, _, _]] ]( - protocol: P + protocol: P, + serviceProvider: Service.Provider[Alg] )(implicit - service: Service[Alg, Op], ce: CompatEffect, protocolTag: ShapeTag[P] ) { import ce._ import org.http4s.implicits._ private val baseUri = uri"http://localhost/" + private val service = serviceProvider.service def getClient(app: HttpApp[IO]): Resource[IO, FunctorAlgebra[Alg, IO]] def codecs: CodecAPI @@ -111,7 +111,7 @@ abstract class ClientHttpComplianceTestCase[ } private[compliancetests] def clientRequestTest[I, E, O, SE, SO]( - endpoint: Endpoint[Op, I, E, O, SE, SO], + endpoint: Endpoint[service.Operation, I, E, O, SE, SO], testCase: HttpRequestTestCase ): ComplianceTest[IO] = { type R[I_, E_, O_, SE_, SO_] = IO[O_] @@ -156,7 +156,7 @@ abstract class ClientHttpComplianceTestCase[ } private[compliancetests] def clientResponseTest[I, E, O, SE, SO]( - endpoint: Endpoint[Op, I, E, O, SE, SO], + endpoint: Endpoint[service.Operation, I, E, O, SE, SO], testCase: HttpResponseTestCase, errorSchema: Option[ErrorResponseTest[_, E]] = None ): ComplianceTest[IO] = { diff --git a/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala b/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala index 5ffe00b8a..4d0a5b8eb 100644 --- a/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala +++ b/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala @@ -38,22 +38,22 @@ import smithy4s.Errorable abstract class ServerHttpComplianceTestCase[ P, - Alg[_[_, _, _, _, _]], - Op[_, _, _, _, _] + Alg[_[_, _, _, _, _]] ]( - protocol: P + protocol: P, + serviceProvider: Service.Provider[Alg] )(implicit - originalService: Service[Alg, Op], ce: CompatEffect, protocolTag: ShapeTag[P] ) { import ce._ import org.http4s.implicits._ + private val originalService = serviceProvider.service private val baseUri = uri"http://localhost/" - def getServer[Alg2[_[_, _, _, _, _]], Op2[_, _, _, _, _]]( + def getServer[Alg2[_[_, _, _, _, _]]]( impl: FunctorAlgebra[Alg2, IO] - )(implicit s: Service[Alg2, Op2]): Resource[IO, HttpRoutes[IO]] + )(implicit s: Service[Alg2]): Resource[IO, HttpRoutes[IO]] def codecs: CodecAPI private def makeRequest( @@ -108,7 +108,7 @@ abstract class ServerHttpComplianceTestCase[ } private[compliancetests] def serverRequestTest[I, E, O, SE, SO]( - endpoint: Endpoint[Op, I, E, O, SE, SO], + endpoint: Endpoint[originalService.Operation, I, E, O, SE, SO], testCase: HttpRequestTestCase ): ComplianceTest[IO] = { type R[I_, E_, O_, SE_, SO_] = IO[O_] @@ -120,9 +120,9 @@ abstract class ServerHttpComplianceTestCase[ deferred[I].flatMap { inputDeferred => val fakeImpl: FunctorAlgebra[Alg, IO] = originalService.fromPolyFunction[R]( - new FunctorInterpreter[Op, IO] { + new FunctorInterpreter[originalService.Operation, IO] { def apply[I_, E_, O_, SE_, SO_]( - op: Op[I_, E_, O_, SE_, SO_] + op: originalService.Operation[I_, E_, O_, SE_, SO_] ): IO[O_] = { val (in, endpointInternal) = originalService.endpoint(op) @@ -154,7 +154,7 @@ abstract class ServerHttpComplianceTestCase[ } private[compliancetests] def serverResponseTest[I, E, O, SE, SO]( - endpoint: Endpoint[Op, I, E, O, SE, SO], + endpoint: Endpoint[originalService.Operation, I, E, O, SE, SO], testCase: HttpResponseTestCase, errorSchema: Option[ErrorResponseTest[_, E]] = None ): ComplianceTest[IO] = { @@ -232,7 +232,7 @@ abstract class ServerHttpComplianceTestCase[ private case class NoInputOp[I_, E_, O_, SE_, SO_]() private def prepareService[I, E, O, SE, SO]( - endpoint: Endpoint[Op, I, E, O, SE, SO] + endpoint: Endpoint[originalService.Operation, I, E, O, SE, SO] ): (Service.Reflective[NoInputOp], Request[IO]) = { val amendedEndpoint = // format: off diff --git a/modules/compliance-tests/test/src/smithy4s/compliancetests/WeaverComplianceTest.scala b/modules/compliance-tests/test/src/smithy4s/compliancetests/WeaverComplianceTest.scala index 2b1ceeb6c..c8889ba1d 100644 --- a/modules/compliance-tests/test/src/smithy4s/compliancetests/WeaverComplianceTest.scala +++ b/modules/compliance-tests/test/src/smithy4s/compliancetests/WeaverComplianceTest.scala @@ -26,12 +26,9 @@ import weaver._ import smithy4s.Service object WeaverComplianceTest extends SimpleIOSuite { - val clientTestGenerator = new ClientHttpComplianceTestCase[ - alloy.SimpleRestJson, - HelloServiceGen, - HelloServiceOperation - ]( - alloy.SimpleRestJson() + val clientTestGenerator = new ClientHttpComplianceTestCase( + alloy.SimpleRestJson(), + HelloService ) { import org.http4s.implicits._ private val baseUri = uri"http://localhost/" @@ -44,20 +41,15 @@ object WeaverComplianceTest extends SimpleIOSuite { def codecs = SimpleRestJsonBuilder.codecs } - val serverTestGenerator = new ServerHttpComplianceTestCase[ - alloy.SimpleRestJson, - HelloServiceGen, - HelloServiceOperation - ]( - alloy.SimpleRestJson() - ) { - def getServer[Alg2[_[_, _, _, _, _]], Op2[_, _, _, _, _]]( - impl: smithy4s.kinds.FunctorAlgebra[Alg2, IO] - )(implicit s: Service[Alg2, Op2]): Resource[IO, HttpRoutes[IO]] = - SimpleRestJsonBuilder(s).routes(impl).resource + val serverTestGenerator = + new ServerHttpComplianceTestCase(alloy.SimpleRestJson(), HelloService) { + def getServer[Alg2[_[_, _, _, _, _]]]( + impl: smithy4s.kinds.FunctorAlgebra[Alg2, IO] + )(implicit s: Service[Alg2]): Resource[IO, HttpRoutes[IO]] = + SimpleRestJsonBuilder(s).routes(impl).resource - def codecs = SimpleRestJsonBuilder.codecs - } + def codecs = SimpleRestJsonBuilder.codecs + } val tests: List[ComplianceTest[IO]] = clientTestGenerator.allClientTests() ++ serverTestGenerator.allServerTests() From 933da5419e28e4f2341cea5f2aa8deda5ecfc87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Wed, 2 Nov 2022 18:17:03 +0100 Subject: [PATCH 03/21] More path-dependant aliases --- modules/aws/src/smithy4s/aws/AwsClient.scala | 2 +- .../codegen/src/smithy4s/codegen/Renderer.scala | 7 ++++--- .../ClientHttpComplianceTestCase.scala | 4 ++-- .../ServerHttpComplianceTestCase.scala | 11 +++++------ modules/core/src/smithy4s/Service.scala | 14 +++++++++----- modules/core/src/smithy4s/http/package.scala | 4 ++-- .../dynamic/internals/DynamicService.scala | 7 +++---- .../src/smithy4s/tests/DummyService.scala | 4 +--- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/modules/aws/src/smithy4s/aws/AwsClient.scala b/modules/aws/src/smithy4s/aws/AwsClient.scala index 009eab162..dd00ea969 100644 --- a/modules/aws/src/smithy4s/aws/AwsClient.scala +++ b/modules/aws/src/smithy4s/aws/AwsClient.scala @@ -58,7 +58,7 @@ object AwsClient { private def interpreter[F[_]: MonadThrow]( awsEnv: AwsEnvironment[F] - ): PolyFunction5[service.Operation, AwsCall[F, *, *, *, *, *]] = + ): service.Interpreter[AwsCall[F, *, *, *, *, *]] = awsProtocol match { case AwsProtocol.AWS_JSON_1_0(_) => new AwsJsonRPCInterpreter[Alg, service.Operation, F]( diff --git a/modules/codegen/src/smithy4s/codegen/Renderer.scala b/modules/codegen/src/smithy4s/codegen/Renderer.scala index 504daad60..e6524b431 100644 --- a/modules/codegen/src/smithy4s/codegen/Renderer.scala +++ b/modules/codegen/src/smithy4s/codegen/Renderer.scala @@ -214,7 +214,7 @@ private[codegen] class Renderer(compilationUnit: CompilationUnit) { self => newline, renderHintsVal(hints), newline, - line"val endpoints: $list[$Endpoint_[$opTraitNameRef, _, _, _, _, _]] = $list" + line"val endpoints: $list[$genNameRef.Endpoint[_, _, _, _, _]] = $list" .args(ops.map(_.name)), newline, line"""val version: String = "$version"""", @@ -296,6 +296,7 @@ private[codegen] class Renderer(compilationUnit: CompilationUnit) { self => val params = if (op.input != Type.unit) { line"input: ${op.input}" } else Line.empty + val genServiceName = serviceName + "Gen" val opName = op.name val opNameRef = NameRef(opName) val traitName = NameRef(s"${serviceName}Operation") @@ -335,11 +336,11 @@ private[codegen] class Renderer(compilationUnit: CompilationUnit) { self => lines( line"case class ${NameDef(opName)}($params) extends $traitName[${op - .renderAlgParams(serviceName + "Gen")}]", + .renderAlgParams(genServiceName)}]", obj( opNameRef, ext = - line"$Endpoint_[${traitName}, ${op.renderAlgParams(serviceName + "Gen")}]$errorable" + line"$genServiceName.Endpoint[${op.renderAlgParams(genServiceName)}]$errorable" )( renderId(op.shapeId), line"val input: $Schema_[${op.input}] = ${op.input.schemaRef}.addHints(smithy4s.internals.InputOutput.Input.widen)", diff --git a/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala b/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala index d842bb6f5..6e6ec6c06 100644 --- a/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala +++ b/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala @@ -111,7 +111,7 @@ abstract class ClientHttpComplianceTestCase[ } private[compliancetests] def clientRequestTest[I, E, O, SE, SO]( - endpoint: Endpoint[service.Operation, I, E, O, SE, SO], + endpoint: service.Endpoint[I, E, O, SE, SO], testCase: HttpRequestTestCase ): ComplianceTest[IO] = { type R[I_, E_, O_, SE_, SO_] = IO[O_] @@ -156,7 +156,7 @@ abstract class ClientHttpComplianceTestCase[ } private[compliancetests] def clientResponseTest[I, E, O, SE, SO]( - endpoint: Endpoint[service.Operation, I, E, O, SE, SO], + endpoint: service.Endpoint[I, E, O, SE, SO], testCase: HttpResponseTestCase, errorSchema: Option[ErrorResponseTest[_, E]] = None ): ComplianceTest[IO] = { diff --git a/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala b/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala index 4d0a5b8eb..ce05726ad 100644 --- a/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala +++ b/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala @@ -108,10 +108,9 @@ abstract class ServerHttpComplianceTestCase[ } private[compliancetests] def serverRequestTest[I, E, O, SE, SO]( - endpoint: Endpoint[originalService.Operation, I, E, O, SE, SO], + endpoint: originalService.Endpoint[I, E, O, SE, SO], testCase: HttpRequestTestCase ): ComplianceTest[IO] = { - type R[I_, E_, O_, SE_, SO_] = IO[O_] val inputFromDocument = Document.Decoder.fromSchema(endpoint.input) ComplianceTest[IO]( @@ -119,8 +118,8 @@ abstract class ServerHttpComplianceTestCase[ run = { deferred[I].flatMap { inputDeferred => val fakeImpl: FunctorAlgebra[Alg, IO] = - originalService.fromPolyFunction[R]( - new FunctorInterpreter[originalService.Operation, IO] { + originalService.fromPolyFunction( + new originalService.FunctorInterpreter[IO] { def apply[I_, E_, O_, SE_, SO_]( op: originalService.Operation[I_, E_, O_, SE_, SO_] ): IO[O_] = { @@ -154,7 +153,7 @@ abstract class ServerHttpComplianceTestCase[ } private[compliancetests] def serverResponseTest[I, E, O, SE, SO]( - endpoint: Endpoint[originalService.Operation, I, E, O, SE, SO], + endpoint: originalService.Endpoint[I, E, O, SE, SO], testCase: HttpResponseTestCase, errorSchema: Option[ErrorResponseTest[_, E]] = None ): ComplianceTest[IO] = { @@ -232,7 +231,7 @@ abstract class ServerHttpComplianceTestCase[ private case class NoInputOp[I_, E_, O_, SE_, SO_]() private def prepareService[I, E, O, SE, SO]( - endpoint: Endpoint[originalService.Operation, I, E, O, SE, SO] + endpoint: originalService.Endpoint[I, E, O, SE, SO] ): (Service.Reflective[NoInputOp], Request[IO]) = { val amendedEndpoint = // format: off diff --git a/modules/core/src/smithy4s/Service.scala b/modules/core/src/smithy4s/Service.scala index 1ede1ea18..fecf1d236 100644 --- a/modules/core/src/smithy4s/Service.scala +++ b/modules/core/src/smithy4s/Service.scala @@ -35,19 +35,23 @@ import kinds._ * metaprogramming. */ trait Service[Alg[_[_, _, _, _, _]]] extends FunctorK5[Alg] with Service.Provider[Alg] { - type Operation[E, I, O, SI, SO] + type Operation[I, E, O, SI, SO] + type Endpoint[I, E, O, SI, SO] = smithy4s.Endpoint[Operation, I, E, O, SI, SO] + type Interpreter[F[_, _, _, _, _]] = PolyFunction5[Operation, F] + type FunctorInterpreter[F[_]] = PolyFunction5[Operation, kinds.Kind1[F]#toKind5] + type BiFunctorInterpreter[F[_, _]] = PolyFunction5[Operation, kinds.Kind2[F]#toKind5] val service: Service[Alg] = this - def endpoints: List[Endpoint[Operation, _, _, _, _, _]] - def endpoint[I, E, O, SI, SO](op: Operation[I, E, O, SI, SO]): (I, Endpoint[Operation, I, E, O, SI, SO]) + def endpoints: List[Endpoint[_, _, _, _, _]] + def endpoint[I, E, O, SI, SO](op: Operation[I, E, O, SI, SO]): (I, Endpoint[I, E, O, SI, SO]) def version: String def hints: Hints def reified: Alg[Operation] def fromPolyFunction[P[_, _, _, _, _]](function: PolyFunction5[Operation, P]): Alg[P] def toPolyFunction[P[_, _, _, _, _]](algebra: Alg[P]): PolyFunction5[Operation, P] - final val opToEndpoint : PolyFunction5[Operation, Endpoint[Operation, *, *, *, *, *]] = new PolyFunction5[Operation, Endpoint[Operation, *, *, *, *, *]]{ - def apply[I, E, O, SI, SO](op: Operation[I,E,O,SI,SO]): Endpoint[Operation,I,E,O,SI,SO] = endpoint(op)._2 + final val opToEndpoint : PolyFunction5[Operation, Endpoint] = new PolyFunction5[Operation, Endpoint]{ + def apply[I, E, O, SI, SO](op: Operation[I,E,O,SI,SO]): Endpoint[I,E,O,SI,SO] = endpoint(op)._2 } } diff --git a/modules/core/src/smithy4s/http/package.scala b/modules/core/src/smithy4s/http/package.scala index 94ccb1254..76d0988ba 100644 --- a/modules/core/src/smithy4s/http/package.scala +++ b/modules/core/src/smithy4s/http/package.scala @@ -27,7 +27,7 @@ package object http { path: String ): Option[ ( - Endpoint[service.Operation, _, _, _, _, _], + service.Endpoint[_, _, _, _, _], http.HttpEndpoint[_], Map[String, String] ) @@ -47,7 +47,7 @@ package object http { pathSegments: Vector[String] ): Option[ ( - Endpoint[service.Operation, _, _, _, _, _], + service.Endpoint[_, _, _, _, _], http.HttpEndpoint[_], Map[String, String] ) diff --git a/modules/dynamic/src/smithy4s/dynamic/internals/DynamicService.scala b/modules/dynamic/src/smithy4s/dynamic/internals/DynamicService.scala index c8a3586ae..86a30c629 100644 --- a/modules/dynamic/src/smithy4s/dynamic/internals/DynamicService.scala +++ b/modules/dynamic/src/smithy4s/dynamic/internals/DynamicService.scala @@ -31,16 +31,15 @@ private[internals] case class DynamicService( type Alg[P[_, _, _, _, _]] = PolyFunction5.From[DynamicOp]#Algebra[P] override val service: Service[Alg] = this - private lazy val endpointMap - : Map[ShapeId, Endpoint[DynamicOp, _, _, _, _, _]] = + private lazy val endpointMap: Map[ShapeId, Endpoint[_, _, _, _, _]] = endpoints.map(ep => ep.id -> ep).toMap def endpoint[I, E, O, SI, SO]( op: DynamicOp[I, E, O, SI, SO] - ): (I, Endpoint[DynamicOp, I, E, O, SI, SO]) = { + ): (I, Endpoint[I, E, O, SI, SO]) = { val endpoint = endpointMap .getOrElse(op.id, sys.error("Unknown endpoint: " + op.id)) - .asInstanceOf[Endpoint[DynamicOp, I, E, O, SI, SO]] + .asInstanceOf[Endpoint[I, E, O, SI, SO]] val input = op.data (input, endpoint) } diff --git a/modules/test-utils/src/smithy4s/tests/DummyService.scala b/modules/test-utils/src/smithy4s/tests/DummyService.scala index 95d524d7c..56d7b87ab 100644 --- a/modules/test-utils/src/smithy4s/tests/DummyService.scala +++ b/modules/test-utils/src/smithy4s/tests/DummyService.scala @@ -32,9 +32,7 @@ object DummyService { type Op[I, E, O, SI, SO] = service.Operation[I, E, O, SI, SO] service.fromPolyFunction[Kind1[F]#toKind5] { service.opToEndpoint.andThen[Kind1[F]#toKind5]( - new PolyFunction5[Endpoint[Op, *, *, *, *, *], Kind1[ - F - ]#toKind5] { + new PolyFunction5[service.Endpoint, Kind1[F]#toKind5] { def apply[I, E, O, SI, SO]( ep: Endpoint[Op, I, E, O, SI, SO] ): F[O] = From f6dcb6537a3b3fefa49fddcca1d133f07f9456ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Wed, 2 Nov 2022 18:20:14 +0100 Subject: [PATCH 04/21] Fix decline --- modules/decline/src/Smithy4sCli.scala | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/modules/decline/src/Smithy4sCli.scala b/modules/decline/src/Smithy4sCli.scala index 192176e24..44ec603d1 100644 --- a/modules/decline/src/Smithy4sCli.scala +++ b/modules/decline/src/Smithy4sCli.scala @@ -24,8 +24,6 @@ import com.monovore.decline.Command import smithy.api.Documentation import smithy.api.ExternalDocumentation import smithy.api.Http -import smithy4s.Endpoint -import smithy4s.Monadic import smithy4s.Service import smithy4s.decline.core._ import smithy4s.decline.util.PrinterApi @@ -45,13 +43,13 @@ final case class Entrypoint[Alg[_[_, _, _, _, _]], F[_]]( * @param service * The service to build a client call for */ -class Smithy4sCli[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _], F[_]: MonadThrow]( +class Smithy4sCli[Alg[_[_, _, _, _, _]], F[_]: MonadThrow]( mainOpts: Opts[Entrypoint[Alg, F]], - service: Service[Alg, Op] + service: Service[Alg] ) { private def protocolSpecificHelp( - endpoint: Endpoint[Op, _, _, _, _, _] + endpoint: service.Endpoint[_, _, _, _, _] ): List[String] = HttpEndpoint .cast(endpoint) @@ -70,7 +68,7 @@ class Smithy4sCli[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _], F[_]: MonadThrow]( .toList private def makeHelpBlocks( - endpoint: Endpoint[Op, _, _, _, _, _] + endpoint: service.Endpoint[_, _, _, _, _] ): List[String] = protocolSpecificHelp(endpoint) ++ endpoint.hints.get[Documentation].map(_.value) ++ @@ -83,7 +81,7 @@ class Smithy4sCli[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _], F[_]: MonadThrow]( ) private def endpointSubcommand[I, E, O]( - endpoint: Endpoint[Op, I, E, O, _, _] + endpoint: service.Endpoint[I, E, O, _, _] ): Opts[F[Unit]] = { def compileToOpts[A](schema: smithy4s.Schema[A]): Opts[A] = @@ -134,12 +132,10 @@ class Smithy4sCli[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _], F[_]: MonadThrow]( } object Smithy4sCli { - def standalone[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _], F[ - _ - ]: Console: MonadThrow]( + def standalone[Alg[_[_, _, _, _, _]], F[_]: Console: MonadThrow]( impl: Opts[FunctorAlgebra[Alg, F]] - )(implicit service: Service[Alg, Op]) = { - new Smithy4sCli[Alg, Op, F]( + )(implicit service: Service[Alg]) = { + new Smithy4sCli[Alg, F]( ( impl, PrinterApi.opts.default[F]() From 768ca6ec327dfe834699e53a16adf84e604ee85f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 12:36:38 +0100 Subject: [PATCH 05/21] Triggering build ? --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 468b2d607..afb9cf9cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: required: false default: 'false' push: - branches: ["main"] + branches: ["main", "series/*"] tags: ["v*"] pull_request: branches: ["*"] From 5b7a723ea68de130b1e42475d4cc06bcb0eb64dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 12:38:51 +0100 Subject: [PATCH 06/21] Revert "Triggering build ?" This reverts commit 768ca6ec327dfe834699e53a16adf84e604ee85f. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afb9cf9cf..468b2d607 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: required: false default: 'false' push: - branches: ["main", "series/*"] + branches: ["main"] tags: ["v*"] pull_request: branches: ["*"] From c562c1b3da6a81314fc40cab0402d16d19e7074d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 12:40:23 +0100 Subject: [PATCH 07/21] Fix glob pattern in ci trigger --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 468b2d607..0d7207b03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ on: branches: ["main"] tags: ["v*"] pull_request: - branches: ["*"] + branches: ["**"] concurrency: group: ci-${{ github.ref }} From 9569fca470a80ffcaaf4587def9c47bf618d543c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 12:42:14 +0100 Subject: [PATCH 08/21] Headers --- modules/core/src-2/kinds/package.scala | 16 ++++++++++++++++ modules/core/src-3/kinds/package.scala | 16 ++++++++++++++++ .../src/smithy4s/capability/Transformation.scala | 16 ++++++++++++++++ .../src/smithy4s/kinds/toPolyFunction5.scala | 16 ++++++++++++++++ .../smithy4s/http/json/JsonCodecApiTests.scala | 16 ++++++++++++++++ 5 files changed, 80 insertions(+) diff --git a/modules/core/src-2/kinds/package.scala b/modules/core/src-2/kinds/package.scala index 2a3a201ed..83e9bbf90 100644 --- a/modules/core/src-2/kinds/package.scala +++ b/modules/core/src-2/kinds/package.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2021-2022 Disney Streaming + * + * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://disneystreaming.github.io/TOST-1.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package smithy4s package object kinds { diff --git a/modules/core/src-3/kinds/package.scala b/modules/core/src-3/kinds/package.scala index 70aea367f..909aa41c3 100644 --- a/modules/core/src-3/kinds/package.scala +++ b/modules/core/src-3/kinds/package.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2021-2022 Disney Streaming + * + * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://disneystreaming.github.io/TOST-1.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package smithy4s package object kinds { diff --git a/modules/core/src/smithy4s/capability/Transformation.scala b/modules/core/src/smithy4s/capability/Transformation.scala index 23280c32d..de9bd3e1e 100644 --- a/modules/core/src/smithy4s/capability/Transformation.scala +++ b/modules/core/src/smithy4s/capability/Transformation.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2021-2022 Disney Streaming + * + * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://disneystreaming.github.io/TOST-1.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package smithy4s package capability diff --git a/modules/core/src/smithy4s/kinds/toPolyFunction5.scala b/modules/core/src/smithy4s/kinds/toPolyFunction5.scala index cd033847a..5798b3f86 100644 --- a/modules/core/src/smithy4s/kinds/toPolyFunction5.scala +++ b/modules/core/src/smithy4s/kinds/toPolyFunction5.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2021-2022 Disney Streaming + * + * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://disneystreaming.github.io/TOST-1.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package smithy4s.kinds object toPolyFunction5 { diff --git a/modules/json/test/src/smithy4s/http/json/JsonCodecApiTests.scala b/modules/json/test/src/smithy4s/http/json/JsonCodecApiTests.scala index 86c230421..8d614c387 100644 --- a/modules/json/test/src/smithy4s/http/json/JsonCodecApiTests.scala +++ b/modules/json/test/src/smithy4s/http/json/JsonCodecApiTests.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2021-2022 Disney Streaming + * + * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://disneystreaming.github.io/TOST-1.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package smithy4s.http.json import munit.FunSuite From eee120fba4c4a9318d441043e057866df79dc032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 12:42:35 +0100 Subject: [PATCH 09/21] Regenerating examples --- .../core/src-2/generated/kinds/functorK.scala | 57 +- .../core/src-2/generated/kinds/kinds.scala | 13 +- .../src/generated/kinds/polyFunctions.scala | 192 ++- .../schema/PartiallyAppliedStruct.scala | 1195 +---------------- .../src/smithy4s/example/BrandService.scala | 9 +- .../src/smithy4s/example/FooService.scala | 9 +- .../src/smithy4s/example/NameCollision.scala | 9 +- .../src/smithy4s/example/ObjectService.scala | 11 +- .../smithy4s/example/StreamedObjects.scala | 11 +- .../collision/ReservedNameService.scala | 15 +- .../smithy4s/example/collision/package.scala | 4 +- .../smithy4s/example/imp/ImportService.scala | 9 +- .../src/smithy4s/example/imp/package.scala | 4 +- .../src/smithy4s/example/package.scala | 20 +- 14 files changed, 177 insertions(+), 1381 deletions(-) diff --git a/modules/core/src-2/generated/kinds/functorK.scala b/modules/core/src-2/generated/kinds/functorK.scala index 98fb9ad22..9d50fbf59 100644 --- a/modules/core/src-2/generated/kinds/functorK.scala +++ b/modules/core/src-2/generated/kinds/functorK.scala @@ -19,58 +19,35 @@ package smithy4s package kinds -trait FunctorK[Alg[_[_]]] { +trait FunctorK[Alg[_[_]]]{ def mapK[F[_], G[_]](alg: Alg[F], function: PolyFunction[F, G]): Alg[G] } object FunctorK { - @inline def apply[Alg[_[_]]](implicit ev: FunctorK[Alg]): FunctorK[Alg] = ev + @inline def apply[Alg[_[_]]](implicit ev: FunctorK[Alg]) : FunctorK[Alg] = ev - implicit def polyfunctionFunctorK[F[_]]: FunctorK[PolyFunction[F, *[_]]] = - new FunctorK[PolyFunction[F, *[_]]] { - def mapK[G[_], H[_]]( - fa: PolyFunction[F, G], - fk: PolyFunction[G, H] - ): PolyFunction[F, H] = fa.andThen(fk) - } + implicit def polyfunctionFunctorK[F[_]]: FunctorK[PolyFunction[F, *[_]]] = new FunctorK[PolyFunction[F, *[_]]] { + def mapK[G[_], H[_]](fa: PolyFunction[F, G], fk: PolyFunction[G, H]): PolyFunction[F, H] = fa.andThen(fk) + } } -trait FunctorK2[Alg[_[_, _]]] { - def mapK2[F[_, _], G[_, _]]( - alg: Alg[F], - function: PolyFunction2[F, G] - ): Alg[G] +trait FunctorK2[Alg[_[_, _]]]{ + def mapK2[F[_, _], G[_, _]](alg: Alg[F], function: PolyFunction2[F, G]): Alg[G] } object FunctorK2 { - @inline def apply[Alg[_[_, _]]](implicit ev: FunctorK2[Alg]): FunctorK2[Alg] = - ev + @inline def apply[Alg[_[_, _]]](implicit ev: FunctorK2[Alg]) : FunctorK2[Alg] = ev - implicit def polyfunctionFunctorK2[F[_, _]] - : FunctorK2[PolyFunction2[F, *[_, _]]] = - new FunctorK2[PolyFunction2[F, *[_, _]]] { - def mapK2[G[_, _], H[_, _]]( - fa: PolyFunction2[F, G], - fk: PolyFunction2[G, H] - ): PolyFunction2[F, H] = fa.andThen(fk) - } + implicit def polyfunctionFunctorK2[F[_, _]]: FunctorK2[PolyFunction2[F, *[_, _]]] = new FunctorK2[PolyFunction2[F, *[_, _]]] { + def mapK2[G[_, _], H[_, _]](fa: PolyFunction2[F, G], fk: PolyFunction2[G, H]): PolyFunction2[F, H] = fa.andThen(fk) + } } -trait FunctorK5[Alg[_[_, _, _, _, _]]] { - def mapK5[F[_, _, _, _, _], G[_, _, _, _, _]]( - alg: Alg[F], - function: PolyFunction5[F, G] - ): Alg[G] +trait FunctorK5[Alg[_[_, _, _, _, _]]]{ + def mapK5[F[_, _, _, _, _], G[_, _, _, _, _]](alg: Alg[F], function: PolyFunction5[F, G]): Alg[G] } object FunctorK5 { - @inline def apply[Alg[_[_, _, _, _, _]]](implicit - ev: FunctorK5[Alg] - ): FunctorK5[Alg] = ev + @inline def apply[Alg[_[_, _, _, _, _]]](implicit ev: FunctorK5[Alg]) : FunctorK5[Alg] = ev - implicit def polyfunctionFunctorK5[F[_, _, _, _, _]] - : FunctorK5[PolyFunction5[F, *[_, _, _, _, _]]] = - new FunctorK5[PolyFunction5[F, *[_, _, _, _, _]]] { - def mapK5[G[_, _, _, _, _], H[_, _, _, _, _]]( - fa: PolyFunction5[F, G], - fk: PolyFunction5[G, H] - ): PolyFunction5[F, H] = fa.andThen(fk) - } + implicit def polyfunctionFunctorK5[F[_, _, _, _, _]]: FunctorK5[PolyFunction5[F, *[_, _, _, _, _]]] = new FunctorK5[PolyFunction5[F, *[_, _, _, _, _]]] { + def mapK5[G[_, _, _, _, _], H[_, _, _, _, _]](fa: PolyFunction5[F, G], fk: PolyFunction5[G, H]): PolyFunction5[F, H] = fa.andThen(fk) + } } diff --git a/modules/core/src-2/generated/kinds/kinds.scala b/modules/core/src-2/generated/kinds/kinds.scala index 9a0ab67e8..a42aae821 100644 --- a/modules/core/src-2/generated/kinds/kinds.scala +++ b/modules/core/src-2/generated/kinds/kinds.scala @@ -19,20 +19,17 @@ package smithy4s package kinds -object Kind1 { +object Kind1{ type Existential[F[_]] = F[_] @inline def existential[F[_], A0](fa: F[A0]): F[_] = fa.asInstanceOf[F[_]] } -object Kind2 { +object Kind2{ type Existential[F[_, _]] = F[_, _] - @inline def existential[F[_, _], A0, A1](fa: F[A0, A1]): F[_, _] = - fa.asInstanceOf[F[_, _]] + @inline def existential[F[_, _], A0, A1](fa: F[A0, A1]): F[_, _] = fa.asInstanceOf[F[_, _]] } -object Kind5 { +object Kind5{ type Existential[F[_, _, _, _, _]] = F[_, _, _, _, _] - @inline def existential[F[_, _, _, _, _], A0, A1, A2, A3, A4]( - fa: F[A0, A1, A2, A3, A4] - ): F[_, _, _, _, _] = fa.asInstanceOf[F[_, _, _, _, _]] + @inline def existential[F[_, _, _, _, _], A0, A1, A2, A3, A4](fa: F[A0, A1, A2, A3, A4]): F[_, _, _, _, _] = fa.asInstanceOf[F[_, _, _, _, _]] } diff --git a/modules/core/src/generated/kinds/polyFunctions.scala b/modules/core/src/generated/kinds/polyFunctions.scala index 407e8ed14..793641de9 100644 --- a/modules/core/src/generated/kinds/polyFunctions.scala +++ b/modules/core/src/generated/kinds/polyFunctions.scala @@ -21,152 +21,116 @@ package kinds import smithy4s.capability._ -trait PolyFunction[F[_], G[_]] { self => - def apply[A0](fa: F[A0]): G[A0] +trait PolyFunction[F[_], G[_]]{ self => + def apply[A0](fa: F[A0]): G[A0] - final def andThen[H[_]](other: PolyFunction[G, H]): PolyFunction[F, H] = - new PolyFunction[F, H] { + final def andThen[H[_]](other: PolyFunction[G, H]): PolyFunction[F, H] = new PolyFunction[F, H]{ def apply[A0](fa: F[A0]): H[A0] = other(self(fa)) - } - - import Kind1._ - private[smithy4s] final def unsafeCacheBy[K]( - allPossibleInputs: Seq[Existential[F]], - getKey: Existential[F] => K - ): PolyFunction[F, G] = - new PolyFunction[F, G] { - private val map: Map[K, Any] = { - val builder = Map.newBuilder[K, Any] - allPossibleInputs.foreach(input => - builder += getKey(input) -> self - .apply(input.asInstanceOf[F[Any]]) - .asInstanceOf[Any] - ) - builder.result() - } - def apply[A0](input: F[A0]): G[A0] = - map(getKey(existential(input))).asInstanceOf[G[A0]] - } + } + + import Kind1._ + private[smithy4s] final def unsafeCacheBy[K](allPossibleInputs: Seq[Existential[F]], getKey: Existential[F] => K): PolyFunction[F, G] = + new PolyFunction[F, G] { + private val map: Map[K, Any] = { + val builder = Map.newBuilder[K, Any] + allPossibleInputs.foreach(input => + builder += getKey(input) -> self + .apply(input.asInstanceOf[F[Any]]) + .asInstanceOf[Any] + ) + builder.result() + } + def apply[A0](input: F[A0]): G[A0] = map(getKey(existential(input))).asInstanceOf[G[A0]] + } } -object PolyFunction { +object PolyFunction{ type From[F[_]] = { type Algebra[G[_]] = PolyFunction[F, G] } - def identity[F[_]]: PolyFunction[F, F] = new PolyFunction[F, F] { + def identity[F[_]] : PolyFunction[F, F] = new PolyFunction[F, F]{ def apply[A0](input: F[A0]): F[A0] = input } - implicit def polyfunction_transformation[Alg[_[_]]: FunctorK, F[_], G[_]] - : Transformation[PolyFunction[F, G], Alg[F], Alg[G]] = - new Transformation[PolyFunction[F, G], Alg[F], Alg[G]] { - def apply(func: PolyFunction[F, G], algF: Alg[F]): Alg[G] = - FunctorK[Alg].mapK(algF, func) + implicit def polyfunction_transformation[Alg[_[_]]: FunctorK, F[_], G[_]]: Transformation[PolyFunction[F, G], Alg[F], Alg[G]] = + new Transformation[PolyFunction[F, G], Alg[F], Alg[G]]{ + def apply(func: PolyFunction[F, G], algF: Alg[F]) : Alg[G] = FunctorK[Alg].mapK(algF, func) } } -trait PolyFunction2[F[_, _], G[_, _]] { self => - def apply[A0, A1](fa: F[A0, A1]): G[A0, A1] +trait PolyFunction2[F[_, _], G[_, _]]{ self => + def apply[A0, A1](fa: F[A0, A1]): G[A0, A1] - final def andThen[H[_, _]](other: PolyFunction2[G, H]): PolyFunction2[F, H] = - new PolyFunction2[F, H] { + final def andThen[H[_, _]](other: PolyFunction2[G, H]): PolyFunction2[F, H] = new PolyFunction2[F, H]{ def apply[A0, A1](fa: F[A0, A1]): H[A0, A1] = other(self(fa)) - } - - import Kind2._ - private[smithy4s] final def unsafeCacheBy[K]( - allPossibleInputs: Seq[Existential[F]], - getKey: Existential[F] => K - ): PolyFunction2[F, G] = - new PolyFunction2[F, G] { - private val map: Map[K, Any] = { - val builder = Map.newBuilder[K, Any] - allPossibleInputs.foreach(input => - builder += getKey(input) -> self - .apply(input.asInstanceOf[F[Any, Any]]) - .asInstanceOf[Any] - ) - builder.result() - } - def apply[A0, A1](input: F[A0, A1]): G[A0, A1] = map( - getKey(existential(input)) - ).asInstanceOf[G[A0, A1]] - } + } + + import Kind2._ + private[smithy4s] final def unsafeCacheBy[K](allPossibleInputs: Seq[Existential[F]], getKey: Existential[F] => K): PolyFunction2[F, G] = + new PolyFunction2[F, G] { + private val map: Map[K, Any] = { + val builder = Map.newBuilder[K, Any] + allPossibleInputs.foreach(input => + builder += getKey(input) -> self + .apply(input.asInstanceOf[F[Any, Any]]) + .asInstanceOf[Any] + ) + builder.result() + } + def apply[A0, A1](input: F[A0, A1]): G[A0, A1] = map(getKey(existential(input))).asInstanceOf[G[A0, A1]] + } } -object PolyFunction2 { +object PolyFunction2{ type From[F[_, _]] = { type Algebra[G[_, _]] = PolyFunction2[F, G] } - def identity[F[_, _]]: PolyFunction2[F, F] = new PolyFunction2[F, F] { + def identity[F[_, _]] : PolyFunction2[F, F] = new PolyFunction2[F, F]{ def apply[A0, A1](input: F[A0, A1]): F[A0, A1] = input } - implicit def polyfunction2_transformation[Alg[_[_, _]]: FunctorK2, F[_, _], G[ - _, - _ - ]]: Transformation[PolyFunction2[F, G], Alg[F], Alg[G]] = - new Transformation[PolyFunction2[F, G], Alg[F], Alg[G]] { - def apply(func: PolyFunction2[F, G], algF: Alg[F]): Alg[G] = - FunctorK2[Alg].mapK2(algF, func) + implicit def polyfunction2_transformation[Alg[_[_, _]]: FunctorK2, F[_, _], G[_, _]]: Transformation[PolyFunction2[F, G], Alg[F], Alg[G]] = + new Transformation[PolyFunction2[F, G], Alg[F], Alg[G]]{ + def apply(func: PolyFunction2[F, G], algF: Alg[F]) : Alg[G] = FunctorK2[Alg].mapK2(algF, func) } } -trait PolyFunction5[F[_, _, _, _, _], G[_, _, _, _, _]] { self => - def apply[A0, A1, A2, A3, A4]( - fa: F[A0, A1, A2, A3, A4] - ): G[A0, A1, A2, A3, A4] - - final def andThen[H[_, _, _, _, _]]( - other: PolyFunction5[G, H] - ): PolyFunction5[F, H] = new PolyFunction5[F, H] { - def apply[A0, A1, A2, A3, A4]( - fa: F[A0, A1, A2, A3, A4] - ): H[A0, A1, A2, A3, A4] = other(self(fa)) - } - import Kind5._ - private[smithy4s] final def unsafeCacheBy[K]( - allPossibleInputs: Seq[Existential[F]], - getKey: Existential[F] => K - ): PolyFunction5[F, G] = - new PolyFunction5[F, G] { - private val map: Map[K, Any] = { - val builder = Map.newBuilder[K, Any] - allPossibleInputs.foreach(input => - builder += getKey(input) -> self - .apply(input.asInstanceOf[F[Any, Any, Any, Any, Any]]) - .asInstanceOf[Any] - ) - builder.result() - } - def apply[A0, A1, A2, A3, A4]( - input: F[A0, A1, A2, A3, A4] - ): G[A0, A1, A2, A3, A4] = - map(getKey(existential(input))).asInstanceOf[G[A0, A1, A2, A3, A4]] - } +trait PolyFunction5[F[_, _, _, _, _], G[_, _, _, _, _]]{ self => + def apply[A0, A1, A2, A3, A4](fa: F[A0, A1, A2, A3, A4]): G[A0, A1, A2, A3, A4] + + final def andThen[H[_, _, _, _, _]](other: PolyFunction5[G, H]): PolyFunction5[F, H] = new PolyFunction5[F, H]{ + def apply[A0, A1, A2, A3, A4](fa: F[A0, A1, A2, A3, A4]): H[A0, A1, A2, A3, A4] = other(self(fa)) + } + + import Kind5._ + private[smithy4s] final def unsafeCacheBy[K](allPossibleInputs: Seq[Existential[F]], getKey: Existential[F] => K): PolyFunction5[F, G] = + new PolyFunction5[F, G] { + private val map: Map[K, Any] = { + val builder = Map.newBuilder[K, Any] + allPossibleInputs.foreach(input => + builder += getKey(input) -> self + .apply(input.asInstanceOf[F[Any, Any, Any, Any, Any]]) + .asInstanceOf[Any] + ) + builder.result() + } + def apply[A0, A1, A2, A3, A4](input: F[A0, A1, A2, A3, A4]): G[A0, A1, A2, A3, A4] = map(getKey(existential(input))).asInstanceOf[G[A0, A1, A2, A3, A4]] + } } -object PolyFunction5 { +object PolyFunction5{ type From[F[_, _, _, _, _]] = { type Algebra[G[_, _, _, _, _]] = PolyFunction5[F, G] } - def identity[F[_, _, _, _, _]]: PolyFunction5[F, F] = - new PolyFunction5[F, F] { - def apply[A0, A1, A2, A3, A4]( - input: F[A0, A1, A2, A3, A4] - ): F[A0, A1, A2, A3, A4] = input - } + def identity[F[_, _, _, _, _]] : PolyFunction5[F, F] = new PolyFunction5[F, F]{ + def apply[A0, A1, A2, A3, A4](input: F[A0, A1, A2, A3, A4]): F[A0, A1, A2, A3, A4] = input + } - implicit def polyfunction5_transformation[Alg[_[_, _, _, _, _]]: FunctorK5, F[ - _, - _, - _, - _, - _ - ], G[_, _, _, _, _]]: Transformation[PolyFunction5[F, G], Alg[F], Alg[G]] = - new Transformation[PolyFunction5[F, G], Alg[F], Alg[G]] { - def apply(func: PolyFunction5[F, G], algF: Alg[F]): Alg[G] = - FunctorK5[Alg].mapK5(algF, func) + implicit def polyfunction5_transformation[Alg[_[_, _, _, _, _]]: FunctorK5, F[_, _, _, _, _], G[_, _, _, _, _]]: Transformation[PolyFunction5[F, G], Alg[F], Alg[G]] = + new Transformation[PolyFunction5[F, G], Alg[F], Alg[G]]{ + def apply(func: PolyFunction5[F, G], algF: Alg[F]) : Alg[G] = FunctorK5[Alg].mapK5(algF, func) } } + + diff --git a/modules/core/src/generated/schema/PartiallyAppliedStruct.scala b/modules/core/src/generated/schema/PartiallyAppliedStruct.scala index f4ab1dff7..d37bb40d0 100644 --- a/modules/core/src/generated/schema/PartiallyAppliedStruct.scala +++ b/modules/core/src/generated/schema/PartiallyAppliedStruct.scala @@ -19,1174 +19,39 @@ package smithy4s package schema -class PartiallyAppliedStruct[S] protected[schema] (placeholder: ShapeId) { +class PartiallyAppliedStruct[S] protected[schema](placeholder: ShapeId) { - def genericArity(fields: SchemaField[S, _]*)( - const: IndexedSeq[Any] => S - ): Schema[S] = + def genericArity( + fields: SchemaField[S, _]*)( + const: IndexedSeq[Any] => S) : Schema[S] = Schema.StructSchema(placeholder, Hints.empty, fields.toVector, const) - def apply(fields: Vector[SchemaField[S, _]])( - const: IndexedSeq[Any] => S - ): Schema[S] = + def apply( + fields: Vector[SchemaField[S, _]])( + const: IndexedSeq[Any] => S) : Schema[S] = Schema.StructSchema(placeholder, Hints.empty, fields, const) - def apply[A0](a0: SchemaField[S, A0])(const: (A0) => S): Schema[S] = - Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0), - arr => const(arr(0).asInstanceOf[A0]) - ) - def apply[A0, A1](a0: SchemaField[S, A0], a1: SchemaField[S, A1])( - const: (A0, A1) => S - ): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1), - arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1]) - ) - def apply[A0, A1, A2]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2] - )(const: (A0, A1, A2) => S): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2] - ) - ) - def apply[A0, A1, A2, A3]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3] - )(const: (A0, A1, A2, A3) => S): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2, a3), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3] - ) - ) - def apply[A0, A1, A2, A3, A4]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4] - )(const: (A0, A1, A2, A3, A4) => S): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2, a3, a4), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4] - ) - ) - def apply[A0, A1, A2, A3, A4, A5]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5] - )(const: (A0, A1, A2, A3, A4, A5) => S): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2, a3, a4, a5), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5] - ) - ) - def apply[A0, A1, A2, A3, A4, A5, A6]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6] - )(const: (A0, A1, A2, A3, A4, A5, A6) => S): Schema[S] = - Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2, a3, a4, a5, a6), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6] - ) - ) - def apply[A0, A1, A2, A3, A4, A5, A6, A7]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7] - )(const: (A0, A1, A2, A3, A4, A5, A6, A7) => S): Schema[S] = - Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2, a3, a4, a5, a6, a7), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7] - ) - ) - def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8] - )(const: (A0, A1, A2, A3, A4, A5, A6, A7, A8) => S): Schema[S] = - Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8] - ) - ) - def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9] - )(const: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9) => S): Schema[S] = - Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9] - ) - ) - def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9], - a10: SchemaField[S, A10] - )(const: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) => S): Schema[S] = - Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9], - arr(10).asInstanceOf[A10] - ) - ) - def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9], - a10: SchemaField[S, A10], - a11: SchemaField[S, A11] - )(const: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) => S): Schema[S] = - Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9], - arr(10).asInstanceOf[A10], - arr(11).asInstanceOf[A11] - ) - ) - def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9], - a10: SchemaField[S, A10], - a11: SchemaField[S, A11], - a12: SchemaField[S, A12] - )( - const: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) => S - ): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9], - arr(10).asInstanceOf[A10], - arr(11).asInstanceOf[A11], - arr(12).asInstanceOf[A12] - ) - ) - def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9], - a10: SchemaField[S, A10], - a11: SchemaField[S, A11], - a12: SchemaField[S, A12], - a13: SchemaField[S, A13] - )( - const: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) => S - ): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9], - arr(10).asInstanceOf[A10], - arr(11).asInstanceOf[A11], - arr(12).asInstanceOf[A12], - arr(13).asInstanceOf[A13] - ) - ) - def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9], - a10: SchemaField[S, A10], - a11: SchemaField[S, A11], - a12: SchemaField[S, A12], - a13: SchemaField[S, A13], - a14: SchemaField[S, A14] - )( - const: ( - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14 - ) => S - ): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9], - arr(10).asInstanceOf[A10], - arr(11).asInstanceOf[A11], - arr(12).asInstanceOf[A12], - arr(13).asInstanceOf[A13], - arr(14).asInstanceOf[A14] - ) - ) - def apply[ - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15 - ]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9], - a10: SchemaField[S, A10], - a11: SchemaField[S, A11], - a12: SchemaField[S, A12], - a13: SchemaField[S, A13], - a14: SchemaField[S, A14], - a15: SchemaField[S, A15] - )( - const: ( - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15 - ) => S - ): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector( - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11, - a12, - a13, - a14, - a15 - ), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9], - arr(10).asInstanceOf[A10], - arr(11).asInstanceOf[A11], - arr(12).asInstanceOf[A12], - arr(13).asInstanceOf[A13], - arr(14).asInstanceOf[A14], - arr(15).asInstanceOf[A15] - ) - ) - def apply[ - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15, - A16 - ]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9], - a10: SchemaField[S, A10], - a11: SchemaField[S, A11], - a12: SchemaField[S, A12], - a13: SchemaField[S, A13], - a14: SchemaField[S, A14], - a15: SchemaField[S, A15], - a16: SchemaField[S, A16] - )( - const: ( - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15, - A16 - ) => S - ): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector( - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11, - a12, - a13, - a14, - a15, - a16 - ), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9], - arr(10).asInstanceOf[A10], - arr(11).asInstanceOf[A11], - arr(12).asInstanceOf[A12], - arr(13).asInstanceOf[A13], - arr(14).asInstanceOf[A14], - arr(15).asInstanceOf[A15], - arr(16).asInstanceOf[A16] - ) - ) - def apply[ - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15, - A16, - A17 - ]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9], - a10: SchemaField[S, A10], - a11: SchemaField[S, A11], - a12: SchemaField[S, A12], - a13: SchemaField[S, A13], - a14: SchemaField[S, A14], - a15: SchemaField[S, A15], - a16: SchemaField[S, A16], - a17: SchemaField[S, A17] - )( - const: ( - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15, - A16, - A17 - ) => S - ): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector( - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11, - a12, - a13, - a14, - a15, - a16, - a17 - ), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9], - arr(10).asInstanceOf[A10], - arr(11).asInstanceOf[A11], - arr(12).asInstanceOf[A12], - arr(13).asInstanceOf[A13], - arr(14).asInstanceOf[A14], - arr(15).asInstanceOf[A15], - arr(16).asInstanceOf[A16], - arr(17).asInstanceOf[A17] - ) - ) - def apply[ - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15, - A16, - A17, - A18 - ]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9], - a10: SchemaField[S, A10], - a11: SchemaField[S, A11], - a12: SchemaField[S, A12], - a13: SchemaField[S, A13], - a14: SchemaField[S, A14], - a15: SchemaField[S, A15], - a16: SchemaField[S, A16], - a17: SchemaField[S, A17], - a18: SchemaField[S, A18] - )( - const: ( - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15, - A16, - A17, - A18 - ) => S - ): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector( - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11, - a12, - a13, - a14, - a15, - a16, - a17, - a18 - ), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9], - arr(10).asInstanceOf[A10], - arr(11).asInstanceOf[A11], - arr(12).asInstanceOf[A12], - arr(13).asInstanceOf[A13], - arr(14).asInstanceOf[A14], - arr(15).asInstanceOf[A15], - arr(16).asInstanceOf[A16], - arr(17).asInstanceOf[A17], - arr(18).asInstanceOf[A18] - ) - ) - def apply[ - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15, - A16, - A17, - A18, - A19 - ]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9], - a10: SchemaField[S, A10], - a11: SchemaField[S, A11], - a12: SchemaField[S, A12], - a13: SchemaField[S, A13], - a14: SchemaField[S, A14], - a15: SchemaField[S, A15], - a16: SchemaField[S, A16], - a17: SchemaField[S, A17], - a18: SchemaField[S, A18], - a19: SchemaField[S, A19] - )( - const: ( - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15, - A16, - A17, - A18, - A19 - ) => S - ): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector( - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11, - a12, - a13, - a14, - a15, - a16, - a17, - a18, - a19 - ), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9], - arr(10).asInstanceOf[A10], - arr(11).asInstanceOf[A11], - arr(12).asInstanceOf[A12], - arr(13).asInstanceOf[A13], - arr(14).asInstanceOf[A14], - arr(15).asInstanceOf[A15], - arr(16).asInstanceOf[A16], - arr(17).asInstanceOf[A17], - arr(18).asInstanceOf[A18], - arr(19).asInstanceOf[A19] - ) - ) - def apply[ - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15, - A16, - A17, - A18, - A19, - A20 - ]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9], - a10: SchemaField[S, A10], - a11: SchemaField[S, A11], - a12: SchemaField[S, A12], - a13: SchemaField[S, A13], - a14: SchemaField[S, A14], - a15: SchemaField[S, A15], - a16: SchemaField[S, A16], - a17: SchemaField[S, A17], - a18: SchemaField[S, A18], - a19: SchemaField[S, A19], - a20: SchemaField[S, A20] - )( - const: ( - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15, - A16, - A17, - A18, - A19, - A20 - ) => S - ): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector( - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11, - a12, - a13, - a14, - a15, - a16, - a17, - a18, - a19, - a20 - ), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9], - arr(10).asInstanceOf[A10], - arr(11).asInstanceOf[A11], - arr(12).asInstanceOf[A12], - arr(13).asInstanceOf[A13], - arr(14).asInstanceOf[A14], - arr(15).asInstanceOf[A15], - arr(16).asInstanceOf[A16], - arr(17).asInstanceOf[A17], - arr(18).asInstanceOf[A18], - arr(19).asInstanceOf[A19], - arr(20).asInstanceOf[A20] - ) - ) - def apply[ - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15, - A16, - A17, - A18, - A19, - A20, - A21 - ]( - a0: SchemaField[S, A0], - a1: SchemaField[S, A1], - a2: SchemaField[S, A2], - a3: SchemaField[S, A3], - a4: SchemaField[S, A4], - a5: SchemaField[S, A5], - a6: SchemaField[S, A6], - a7: SchemaField[S, A7], - a8: SchemaField[S, A8], - a9: SchemaField[S, A9], - a10: SchemaField[S, A10], - a11: SchemaField[S, A11], - a12: SchemaField[S, A12], - a13: SchemaField[S, A13], - a14: SchemaField[S, A14], - a15: SchemaField[S, A15], - a16: SchemaField[S, A16], - a17: SchemaField[S, A17], - a18: SchemaField[S, A18], - a19: SchemaField[S, A19], - a20: SchemaField[S, A20], - a21: SchemaField[S, A21] - )( - const: ( - A0, - A1, - A2, - A3, - A4, - A5, - A6, - A7, - A8, - A9, - A10, - A11, - A12, - A13, - A14, - A15, - A16, - A17, - A18, - A19, - A20, - A21 - ) => S - ): Schema[S] = Schema.StructSchema[S]( - placeholder, - Hints.empty, - Vector( - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11, - a12, - a13, - a14, - a15, - a16, - a17, - a18, - a19, - a20, - a21 - ), - arr => - const( - arr(0).asInstanceOf[A0], - arr(1).asInstanceOf[A1], - arr(2).asInstanceOf[A2], - arr(3).asInstanceOf[A3], - arr(4).asInstanceOf[A4], - arr(5).asInstanceOf[A5], - arr(6).asInstanceOf[A6], - arr(7).asInstanceOf[A7], - arr(8).asInstanceOf[A8], - arr(9).asInstanceOf[A9], - arr(10).asInstanceOf[A10], - arr(11).asInstanceOf[A11], - arr(12).asInstanceOf[A12], - arr(13).asInstanceOf[A13], - arr(14).asInstanceOf[A14], - arr(15).asInstanceOf[A15], - arr(16).asInstanceOf[A16], - arr(17).asInstanceOf[A17], - arr(18).asInstanceOf[A18], - arr(19).asInstanceOf[A19], - arr(20).asInstanceOf[A20], - arr(21).asInstanceOf[A21] - ) - ) + def apply[A0](a0: SchemaField[S, A0])(const : (A0) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0), arr => const(arr(0).asInstanceOf[A0])) + def apply[A0, A1](a0: SchemaField[S, A0], a1: SchemaField[S, A1])(const : (A0, A1) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1])) + def apply[A0, A1, A2](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2])(const : (A0, A1, A2) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2])) + def apply[A0, A1, A2, A3](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3])(const : (A0, A1, A2, A3) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3])) + def apply[A0, A1, A2, A3, A4](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4])(const : (A0, A1, A2, A3, A4) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4])) + def apply[A0, A1, A2, A3, A4, A5](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5])(const : (A0, A1, A2, A3, A4, A5) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5])) + def apply[A0, A1, A2, A3, A4, A5, A6](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6])(const : (A0, A1, A2, A3, A4, A5, A6) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7])(const : (A0, A1, A2, A3, A4, A5, A6, A7) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9], a10: SchemaField[S, A10])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9], arr(10).asInstanceOf[A10])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9], a10: SchemaField[S, A10], a11: SchemaField[S, A11])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9], arr(10).asInstanceOf[A10], arr(11).asInstanceOf[A11])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9], a10: SchemaField[S, A10], a11: SchemaField[S, A11], a12: SchemaField[S, A12])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9], arr(10).asInstanceOf[A10], arr(11).asInstanceOf[A11], arr(12).asInstanceOf[A12])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9], a10: SchemaField[S, A10], a11: SchemaField[S, A11], a12: SchemaField[S, A12], a13: SchemaField[S, A13])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9], arr(10).asInstanceOf[A10], arr(11).asInstanceOf[A11], arr(12).asInstanceOf[A12], arr(13).asInstanceOf[A13])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9], a10: SchemaField[S, A10], a11: SchemaField[S, A11], a12: SchemaField[S, A12], a13: SchemaField[S, A13], a14: SchemaField[S, A14])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9], arr(10).asInstanceOf[A10], arr(11).asInstanceOf[A11], arr(12).asInstanceOf[A12], arr(13).asInstanceOf[A13], arr(14).asInstanceOf[A14])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9], a10: SchemaField[S, A10], a11: SchemaField[S, A11], a12: SchemaField[S, A12], a13: SchemaField[S, A13], a14: SchemaField[S, A14], a15: SchemaField[S, A15])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9], arr(10).asInstanceOf[A10], arr(11).asInstanceOf[A11], arr(12).asInstanceOf[A12], arr(13).asInstanceOf[A13], arr(14).asInstanceOf[A14], arr(15).asInstanceOf[A15])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9], a10: SchemaField[S, A10], a11: SchemaField[S, A11], a12: SchemaField[S, A12], a13: SchemaField[S, A13], a14: SchemaField[S, A14], a15: SchemaField[S, A15], a16: SchemaField[S, A16])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9], arr(10).asInstanceOf[A10], arr(11).asInstanceOf[A11], arr(12).asInstanceOf[A12], arr(13).asInstanceOf[A13], arr(14).asInstanceOf[A14], arr(15).asInstanceOf[A15], arr(16).asInstanceOf[A16])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9], a10: SchemaField[S, A10], a11: SchemaField[S, A11], a12: SchemaField[S, A12], a13: SchemaField[S, A13], a14: SchemaField[S, A14], a15: SchemaField[S, A15], a16: SchemaField[S, A16], a17: SchemaField[S, A17])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9], arr(10).asInstanceOf[A10], arr(11).asInstanceOf[A11], arr(12).asInstanceOf[A12], arr(13).asInstanceOf[A13], arr(14).asInstanceOf[A14], arr(15).asInstanceOf[A15], arr(16).asInstanceOf[A16], arr(17).asInstanceOf[A17])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9], a10: SchemaField[S, A10], a11: SchemaField[S, A11], a12: SchemaField[S, A12], a13: SchemaField[S, A13], a14: SchemaField[S, A14], a15: SchemaField[S, A15], a16: SchemaField[S, A16], a17: SchemaField[S, A17], a18: SchemaField[S, A18])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9], arr(10).asInstanceOf[A10], arr(11).asInstanceOf[A11], arr(12).asInstanceOf[A12], arr(13).asInstanceOf[A13], arr(14).asInstanceOf[A14], arr(15).asInstanceOf[A15], arr(16).asInstanceOf[A16], arr(17).asInstanceOf[A17], arr(18).asInstanceOf[A18])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9], a10: SchemaField[S, A10], a11: SchemaField[S, A11], a12: SchemaField[S, A12], a13: SchemaField[S, A13], a14: SchemaField[S, A14], a15: SchemaField[S, A15], a16: SchemaField[S, A16], a17: SchemaField[S, A17], a18: SchemaField[S, A18], a19: SchemaField[S, A19])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9], arr(10).asInstanceOf[A10], arr(11).asInstanceOf[A11], arr(12).asInstanceOf[A12], arr(13).asInstanceOf[A13], arr(14).asInstanceOf[A14], arr(15).asInstanceOf[A15], arr(16).asInstanceOf[A16], arr(17).asInstanceOf[A17], arr(18).asInstanceOf[A18], arr(19).asInstanceOf[A19])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9], a10: SchemaField[S, A10], a11: SchemaField[S, A11], a12: SchemaField[S, A12], a13: SchemaField[S, A13], a14: SchemaField[S, A14], a15: SchemaField[S, A15], a16: SchemaField[S, A16], a17: SchemaField[S, A17], a18: SchemaField[S, A18], a19: SchemaField[S, A19], a20: SchemaField[S, A20])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9], arr(10).asInstanceOf[A10], arr(11).asInstanceOf[A11], arr(12).asInstanceOf[A12], arr(13).asInstanceOf[A13], arr(14).asInstanceOf[A14], arr(15).asInstanceOf[A15], arr(16).asInstanceOf[A16], arr(17).asInstanceOf[A17], arr(18).asInstanceOf[A18], arr(19).asInstanceOf[A19], arr(20).asInstanceOf[A20])) + def apply[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21](a0: SchemaField[S, A0], a1: SchemaField[S, A1], a2: SchemaField[S, A2], a3: SchemaField[S, A3], a4: SchemaField[S, A4], a5: SchemaField[S, A5], a6: SchemaField[S, A6], a7: SchemaField[S, A7], a8: SchemaField[S, A8], a9: SchemaField[S, A9], a10: SchemaField[S, A10], a11: SchemaField[S, A11], a12: SchemaField[S, A12], a13: SchemaField[S, A13], a14: SchemaField[S, A14], a15: SchemaField[S, A15], a16: SchemaField[S, A16], a17: SchemaField[S, A17], a18: SchemaField[S, A18], a19: SchemaField[S, A19], a20: SchemaField[S, A20], a21: SchemaField[S, A21])(const : (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21) => S) : Schema[S] = Schema.StructSchema[S](placeholder, Hints.empty, Vector(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21), arr => const(arr(0).asInstanceOf[A0], arr(1).asInstanceOf[A1], arr(2).asInstanceOf[A2], arr(3).asInstanceOf[A3], arr(4).asInstanceOf[A4], arr(5).asInstanceOf[A5], arr(6).asInstanceOf[A6], arr(7).asInstanceOf[A7], arr(8).asInstanceOf[A8], arr(9).asInstanceOf[A9], arr(10).asInstanceOf[A10], arr(11).asInstanceOf[A11], arr(12).asInstanceOf[A12], arr(13).asInstanceOf[A13], arr(14).asInstanceOf[A14], arr(15).asInstanceOf[A15], arr(16).asInstanceOf[A16], arr(17).asInstanceOf[A17], arr(18).asInstanceOf[A18], arr(19).asInstanceOf[A19], arr(20).asInstanceOf[A20], arr(21).asInstanceOf[A21])) -} +} \ No newline at end of file diff --git a/modules/example/src/smithy4s/example/BrandService.scala b/modules/example/src/smithy4s/example/BrandService.scala index 8a4bb25d2..71d9d69ee 100644 --- a/modules/example/src/smithy4s/example/BrandService.scala +++ b/modules/example/src/smithy4s/example/BrandService.scala @@ -3,13 +3,12 @@ package smithy4s.example import smithy4s.Schema import smithy4s.schema.Schema.unit import smithy4s.kinds.PolyFunction5 +import smithy4s.ShapeId import smithy4s.Service import smithy4s.Hints import smithy4s.StreamingSchema import smithy4s.kinds.FunctorAlgebra import smithy4s.capability.Transformation -import smithy4s.ShapeId -import smithy4s.Endpoint trait BrandServiceGen[F[_, _, _, _, _]] { self => @@ -19,7 +18,7 @@ trait BrandServiceGen[F[_, _, _, _, _]] { def transform : Transformation.PartiallyApplied[BrandServiceGen[F]] = new Transformation.PartiallyApplied[BrandServiceGen[F]](this) } -object BrandServiceGen extends Service[BrandServiceGen, BrandServiceOperation] { +object BrandServiceGen extends Service.Mixin[BrandServiceGen, BrandServiceOperation] { def apply[F[_]](implicit F: FunctorAlgebra[BrandServiceGen, F]): F.type = F @@ -27,7 +26,7 @@ object BrandServiceGen extends Service[BrandServiceGen, BrandServiceOperation] { val hints : Hints = Hints.empty - val endpoints: List[Endpoint[BrandServiceOperation, _, _, _, _, _]] = List( + val endpoints: List[BrandServiceGen.Endpoint[_, _, _, _, _]] = List( AddBrands, ) @@ -54,7 +53,7 @@ object BrandServiceGen extends Service[BrandServiceGen, BrandServiceOperation] { } } case class AddBrands(input: AddBrandsInput) extends BrandServiceOperation[AddBrandsInput, Nothing, Unit, Nothing, Nothing] - object AddBrands extends Endpoint[BrandServiceOperation, AddBrandsInput, Nothing, Unit, Nothing, Nothing] { + object AddBrands extends BrandServiceGen.Endpoint[AddBrandsInput, Nothing, Unit, Nothing, Nothing] { val id: ShapeId = ShapeId("smithy4s.example", "AddBrands") val input: Schema[AddBrandsInput] = AddBrandsInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen) val output: Schema[Unit] = unit.addHints(smithy4s.internals.InputOutput.Output.widen) diff --git a/modules/example/src/smithy4s/example/FooService.scala b/modules/example/src/smithy4s/example/FooService.scala index 66fb5cfee..eb8d4e7c9 100644 --- a/modules/example/src/smithy4s/example/FooService.scala +++ b/modules/example/src/smithy4s/example/FooService.scala @@ -3,13 +3,12 @@ package smithy4s.example import smithy4s.Schema import smithy4s.schema.Schema.unit import smithy4s.kinds.PolyFunction5 +import smithy4s.ShapeId import smithy4s.Service import smithy4s.Hints import smithy4s.StreamingSchema import smithy4s.kinds.FunctorAlgebra import smithy4s.capability.Transformation -import smithy4s.ShapeId -import smithy4s.Endpoint trait FooServiceGen[F[_, _, _, _, _]] { self => @@ -19,7 +18,7 @@ trait FooServiceGen[F[_, _, _, _, _]] { def transform : Transformation.PartiallyApplied[FooServiceGen[F]] = new Transformation.PartiallyApplied[FooServiceGen[F]](this) } -object FooServiceGen extends Service[FooServiceGen, FooServiceOperation] { +object FooServiceGen extends Service.Mixin[FooServiceGen, FooServiceOperation] { def apply[F[_]](implicit F: FunctorAlgebra[FooServiceGen, F]): F.type = F @@ -27,7 +26,7 @@ object FooServiceGen extends Service[FooServiceGen, FooServiceOperation] { val hints : Hints = Hints.empty - val endpoints: List[Endpoint[FooServiceOperation, _, _, _, _, _]] = List( + val endpoints: List[FooServiceGen.Endpoint[_, _, _, _, _]] = List( GetFoo, ) @@ -54,7 +53,7 @@ object FooServiceGen extends Service[FooServiceGen, FooServiceOperation] { } } case class GetFoo() extends FooServiceOperation[Unit, Nothing, GetFooOutput, Nothing, Nothing] - object GetFoo extends Endpoint[FooServiceOperation, Unit, Nothing, GetFooOutput, Nothing, Nothing] { + object GetFoo extends FooServiceGen.Endpoint[Unit, Nothing, GetFooOutput, Nothing, Nothing] { val id: ShapeId = ShapeId("smithy4s.example", "GetFoo") val input: Schema[Unit] = unit.addHints(smithy4s.internals.InputOutput.Input.widen) val output: Schema[GetFooOutput] = GetFooOutput.schema.addHints(smithy4s.internals.InputOutput.Output.widen) diff --git a/modules/example/src/smithy4s/example/NameCollision.scala b/modules/example/src/smithy4s/example/NameCollision.scala index 7dd75dc6d..bbc44231b 100644 --- a/modules/example/src/smithy4s/example/NameCollision.scala +++ b/modules/example/src/smithy4s/example/NameCollision.scala @@ -4,6 +4,7 @@ import smithy4s.Errorable import smithy4s.Schema import smithy4s.schema.Schema.unit import smithy4s.kinds.PolyFunction5 +import smithy4s.ShapeId import smithy4s.Service import smithy4s.ShapeTag import smithy4s.schema.Schema.bijection @@ -13,8 +14,6 @@ import smithy4s.Hints import smithy4s.StreamingSchema import smithy4s.kinds.FunctorAlgebra import smithy4s.capability.Transformation -import smithy4s.ShapeId -import smithy4s.Endpoint trait NameCollisionGen[F[_, _, _, _, _]] { self => @@ -24,7 +23,7 @@ trait NameCollisionGen[F[_, _, _, _, _]] { def transform : Transformation.PartiallyApplied[NameCollisionGen[F]] = new Transformation.PartiallyApplied[NameCollisionGen[F]](this) } -object NameCollisionGen extends Service[NameCollisionGen, NameCollisionOperation] { +object NameCollisionGen extends Service.Mixin[NameCollisionGen, NameCollisionOperation] { def apply[F[_]](implicit F: FunctorAlgebra[NameCollisionGen, F]): F.type = F @@ -32,7 +31,7 @@ object NameCollisionGen extends Service[NameCollisionGen, NameCollisionOperation val hints : Hints = Hints.empty - val endpoints: List[Endpoint[NameCollisionOperation, _, _, _, _, _]] = List( + val endpoints: List[NameCollisionGen.Endpoint[_, _, _, _, _]] = List( MyOp, ) @@ -59,7 +58,7 @@ object NameCollisionGen extends Service[NameCollisionGen, NameCollisionOperation } } case class MyOp() extends NameCollisionOperation[Unit, NameCollisionGen.MyOpError, Unit, Nothing, Nothing] - object MyOp extends Endpoint[NameCollisionOperation, Unit, NameCollisionGen.MyOpError, Unit, Nothing, Nothing] with Errorable[MyOpError] { + object MyOp extends NameCollisionGen.Endpoint[Unit, NameCollisionGen.MyOpError, Unit, Nothing, Nothing] with Errorable[MyOpError] { val id: ShapeId = ShapeId("smithy4s.example", "MyOp") val input: Schema[Unit] = unit.addHints(smithy4s.internals.InputOutput.Input.widen) val output: Schema[Unit] = unit.addHints(smithy4s.internals.InputOutput.Output.widen) diff --git a/modules/example/src/smithy4s/example/ObjectService.scala b/modules/example/src/smithy4s/example/ObjectService.scala index b2a2ce882..16b6dd437 100644 --- a/modules/example/src/smithy4s/example/ObjectService.scala +++ b/modules/example/src/smithy4s/example/ObjectService.scala @@ -4,6 +4,7 @@ import smithy4s.Errorable import smithy4s.Schema import smithy4s.schema.Schema.unit import smithy4s.kinds.PolyFunction5 +import smithy4s.ShapeId import smithy4s.Service import smithy4s.ShapeTag import smithy4s.schema.Schema.bijection @@ -13,8 +14,6 @@ import smithy4s.Hints import smithy4s.StreamingSchema import smithy4s.kinds.FunctorAlgebra import smithy4s.capability.Transformation -import smithy4s.ShapeId -import smithy4s.Endpoint trait ObjectServiceGen[F[_, _, _, _, _]] { self => @@ -25,7 +24,7 @@ trait ObjectServiceGen[F[_, _, _, _, _]] { def transform : Transformation.PartiallyApplied[ObjectServiceGen[F]] = new Transformation.PartiallyApplied[ObjectServiceGen[F]](this) } -object ObjectServiceGen extends Service[ObjectServiceGen, ObjectServiceOperation] { +object ObjectServiceGen extends Service.Mixin[ObjectServiceGen, ObjectServiceOperation] { def apply[F[_]](implicit F: FunctorAlgebra[ObjectServiceGen, F]): F.type = F @@ -35,7 +34,7 @@ object ObjectServiceGen extends Service[ObjectServiceGen, ObjectServiceOperation alloy.SimpleRestJson(), ) - val endpoints: List[Endpoint[ObjectServiceOperation, _, _, _, _, _]] = List( + val endpoints: List[ObjectServiceGen.Endpoint[_, _, _, _, _]] = List( PutObject, GetObject, ) @@ -67,7 +66,7 @@ object ObjectServiceGen extends Service[ObjectServiceGen, ObjectServiceOperation } } case class PutObject(input: PutObjectInput) extends ObjectServiceOperation[PutObjectInput, ObjectServiceGen.PutObjectError, Unit, Nothing, Nothing] - object PutObject extends Endpoint[ObjectServiceOperation, PutObjectInput, ObjectServiceGen.PutObjectError, Unit, Nothing, Nothing] with Errorable[PutObjectError] { + object PutObject extends ObjectServiceGen.Endpoint[PutObjectInput, ObjectServiceGen.PutObjectError, Unit, Nothing, Nothing] with Errorable[PutObjectError] { val id: ShapeId = ShapeId("smithy4s.example", "PutObject") val input: Schema[PutObjectInput] = PutObjectInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen) val output: Schema[Unit] = unit.addHints(smithy4s.internals.InputOutput.Output.widen) @@ -121,7 +120,7 @@ object ObjectServiceGen extends Service[ObjectServiceGen, ObjectServiceOperation } } case class GetObject(input: GetObjectInput) extends ObjectServiceOperation[GetObjectInput, ObjectServiceGen.GetObjectError, GetObjectOutput, Nothing, Nothing] - object GetObject extends Endpoint[ObjectServiceOperation, GetObjectInput, ObjectServiceGen.GetObjectError, GetObjectOutput, Nothing, Nothing] with Errorable[GetObjectError] { + object GetObject extends ObjectServiceGen.Endpoint[GetObjectInput, ObjectServiceGen.GetObjectError, GetObjectOutput, Nothing, Nothing] with Errorable[GetObjectError] { val id: ShapeId = ShapeId("smithy4s.example", "GetObject") val input: Schema[GetObjectInput] = GetObjectInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen) val output: Schema[GetObjectOutput] = GetObjectOutput.schema.addHints(smithy4s.internals.InputOutput.Output.widen) diff --git a/modules/example/src/smithy4s/example/StreamedObjects.scala b/modules/example/src/smithy4s/example/StreamedObjects.scala index fddeca094..13e46ab38 100644 --- a/modules/example/src/smithy4s/example/StreamedObjects.scala +++ b/modules/example/src/smithy4s/example/StreamedObjects.scala @@ -3,13 +3,12 @@ package smithy4s.example import smithy4s.Schema import smithy4s.schema.Schema.unit import smithy4s.kinds.PolyFunction5 +import smithy4s.ShapeId import smithy4s.Service import smithy4s.Hints import smithy4s.StreamingSchema import smithy4s.kinds.FunctorAlgebra import smithy4s.capability.Transformation -import smithy4s.ShapeId -import smithy4s.Endpoint trait StreamedObjectsGen[F[_, _, _, _, _]] { self => @@ -20,7 +19,7 @@ trait StreamedObjectsGen[F[_, _, _, _, _]] { def transform : Transformation.PartiallyApplied[StreamedObjectsGen[F]] = new Transformation.PartiallyApplied[StreamedObjectsGen[F]](this) } -object StreamedObjectsGen extends Service[StreamedObjectsGen, StreamedObjectsOperation] { +object StreamedObjectsGen extends Service.Mixin[StreamedObjectsGen, StreamedObjectsOperation] { def apply[F[_]](implicit F: FunctorAlgebra[StreamedObjectsGen, F]): F.type = F @@ -28,7 +27,7 @@ object StreamedObjectsGen extends Service[StreamedObjectsGen, StreamedObjectsOpe val hints : Hints = Hints.empty - val endpoints: List[Endpoint[StreamedObjectsOperation, _, _, _, _, _]] = List( + val endpoints: List[StreamedObjectsGen.Endpoint[_, _, _, _, _]] = List( PutStreamedObject, GetStreamedObject, ) @@ -60,7 +59,7 @@ object StreamedObjectsGen extends Service[StreamedObjectsGen, StreamedObjectsOpe } } case class PutStreamedObject(input: PutStreamedObjectInput) extends StreamedObjectsOperation[PutStreamedObjectInput, Nothing, Unit, StreamedBlob, Nothing] - object PutStreamedObject extends Endpoint[StreamedObjectsOperation, PutStreamedObjectInput, Nothing, Unit, StreamedBlob, Nothing] { + object PutStreamedObject extends StreamedObjectsGen.Endpoint[PutStreamedObjectInput, Nothing, Unit, StreamedBlob, Nothing] { val id: ShapeId = ShapeId("smithy4s.example", "PutStreamedObject") val input: Schema[PutStreamedObjectInput] = PutStreamedObjectInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen) val output: Schema[Unit] = unit.addHints(smithy4s.internals.InputOutput.Output.widen) @@ -70,7 +69,7 @@ object StreamedObjectsGen extends Service[StreamedObjectsGen, StreamedObjectsOpe def wrap(input: PutStreamedObjectInput) = PutStreamedObject(input) } case class GetStreamedObject(input: GetStreamedObjectInput) extends StreamedObjectsOperation[GetStreamedObjectInput, Nothing, GetStreamedObjectOutput, Nothing, StreamedBlob] - object GetStreamedObject extends Endpoint[StreamedObjectsOperation, GetStreamedObjectInput, Nothing, GetStreamedObjectOutput, Nothing, StreamedBlob] { + object GetStreamedObject extends StreamedObjectsGen.Endpoint[GetStreamedObjectInput, Nothing, GetStreamedObjectOutput, Nothing, StreamedBlob] { val id: ShapeId = ShapeId("smithy4s.example", "GetStreamedObject") val input: Schema[GetStreamedObjectInput] = GetStreamedObjectInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen) val output: Schema[GetStreamedObjectOutput] = GetStreamedObjectOutput.schema.addHints(smithy4s.internals.InputOutput.Output.widen) diff --git a/modules/example/src/smithy4s/example/collision/ReservedNameService.scala b/modules/example/src/smithy4s/example/collision/ReservedNameService.scala index 83e42bb44..2ee8089c5 100644 --- a/modules/example/src/smithy4s/example/collision/ReservedNameService.scala +++ b/modules/example/src/smithy4s/example/collision/ReservedNameService.scala @@ -3,13 +3,12 @@ package smithy4s.example.collision import smithy4s.Schema import smithy4s.schema.Schema.unit import smithy4s.kinds.PolyFunction5 +import smithy4s.ShapeId import smithy4s.Service import smithy4s.Hints import smithy4s.StreamingSchema import smithy4s.kinds.FunctorAlgebra import smithy4s.capability.Transformation -import smithy4s.ShapeId -import smithy4s.Endpoint trait ReservedNameServiceGen[F[_, _, _, _, _]] { self => @@ -22,7 +21,7 @@ trait ReservedNameServiceGen[F[_, _, _, _, _]] { def transform : Transformation.PartiallyApplied[ReservedNameServiceGen[F]] = new Transformation.PartiallyApplied[ReservedNameServiceGen[F]](this) } -object ReservedNameServiceGen extends Service[ReservedNameServiceGen, ReservedNameServiceOperation] { +object ReservedNameServiceGen extends Service.Mixin[ReservedNameServiceGen, ReservedNameServiceOperation] { def apply[F[_]](implicit F: FunctorAlgebra[ReservedNameServiceGen, F]): F.type = F @@ -32,7 +31,7 @@ object ReservedNameServiceGen extends Service[ReservedNameServiceGen, ReservedNa alloy.SimpleRestJson(), ) - val endpoints: List[Endpoint[ReservedNameServiceOperation, _, _, _, _, _]] = List( + val endpoints: List[ReservedNameServiceGen.Endpoint[_, _, _, _, _]] = List( _Set, _List, _Map, @@ -74,7 +73,7 @@ object ReservedNameServiceGen extends Service[ReservedNameServiceGen, ReservedNa } } case class _Set(input: SetInput) extends ReservedNameServiceOperation[SetInput, Nothing, Unit, Nothing, Nothing] - object _Set extends Endpoint[ReservedNameServiceOperation, SetInput, Nothing, Unit, Nothing, Nothing] { + object _Set extends ReservedNameServiceGen.Endpoint[SetInput, Nothing, Unit, Nothing, Nothing] { val id: ShapeId = ShapeId("smithy4s.example.collision", "Set") val input: Schema[SetInput] = SetInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen) val output: Schema[Unit] = unit.addHints(smithy4s.internals.InputOutput.Output.widen) @@ -86,7 +85,7 @@ object ReservedNameServiceGen extends Service[ReservedNameServiceGen, ReservedNa def wrap(input: SetInput) = _Set(input) } case class _List(input: ListInput) extends ReservedNameServiceOperation[ListInput, Nothing, Unit, Nothing, Nothing] - object _List extends Endpoint[ReservedNameServiceOperation, ListInput, Nothing, Unit, Nothing, Nothing] { + object _List extends ReservedNameServiceGen.Endpoint[ListInput, Nothing, Unit, Nothing, Nothing] { val id: ShapeId = ShapeId("smithy4s.example.collision", "List") val input: Schema[ListInput] = ListInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen) val output: Schema[Unit] = unit.addHints(smithy4s.internals.InputOutput.Output.widen) @@ -98,7 +97,7 @@ object ReservedNameServiceGen extends Service[ReservedNameServiceGen, ReservedNa def wrap(input: ListInput) = _List(input) } case class _Map(input: MapInput) extends ReservedNameServiceOperation[MapInput, Nothing, Unit, Nothing, Nothing] - object _Map extends Endpoint[ReservedNameServiceOperation, MapInput, Nothing, Unit, Nothing, Nothing] { + object _Map extends ReservedNameServiceGen.Endpoint[MapInput, Nothing, Unit, Nothing, Nothing] { val id: ShapeId = ShapeId("smithy4s.example.collision", "Map") val input: Schema[MapInput] = MapInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen) val output: Schema[Unit] = unit.addHints(smithy4s.internals.InputOutput.Output.widen) @@ -110,7 +109,7 @@ object ReservedNameServiceGen extends Service[ReservedNameServiceGen, ReservedNa def wrap(input: MapInput) = _Map(input) } case class _Option(input: OptionInput) extends ReservedNameServiceOperation[OptionInput, Nothing, Unit, Nothing, Nothing] - object _Option extends Endpoint[ReservedNameServiceOperation, OptionInput, Nothing, Unit, Nothing, Nothing] { + object _Option extends ReservedNameServiceGen.Endpoint[OptionInput, Nothing, Unit, Nothing, Nothing] { val id: ShapeId = ShapeId("smithy4s.example.collision", "Option") val input: Schema[OptionInput] = OptionInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen) val output: Schema[Unit] = unit.addHints(smithy4s.internals.InputOutput.Output.widen) diff --git a/modules/example/src/smithy4s/example/collision/package.scala b/modules/example/src/smithy4s/example/collision/package.scala index d77c6ee9a..12695bf8d 100644 --- a/modules/example/src/smithy4s/example/collision/package.scala +++ b/modules/example/src/smithy4s/example/collision/package.scala @@ -2,9 +2,9 @@ package smithy4s.example package object collision { type ReservedNameService[F[_]] = smithy4s.kinds.FunctorAlgebra[ReservedNameServiceGen, F] - object ReservedNameService extends smithy4s.Service.Provider[ReservedNameServiceGen, ReservedNameServiceOperation] { + object ReservedNameService extends smithy4s.Service.Provider[ReservedNameServiceGen] { def apply[F[_]](implicit F: ReservedNameService[F]): F.type = F - def service: smithy4s.Service[ReservedNameServiceGen, ReservedNameServiceOperation] = ReservedNameServiceGen + def service: smithy4s.Service[ReservedNameServiceGen] = ReservedNameServiceGen val id: smithy4s.ShapeId = service.id } diff --git a/modules/example/src/smithy4s/example/imp/ImportService.scala b/modules/example/src/smithy4s/example/imp/ImportService.scala index 037af6b17..a26dd0ed3 100644 --- a/modules/example/src/smithy4s/example/imp/ImportService.scala +++ b/modules/example/src/smithy4s/example/imp/ImportService.scala @@ -5,6 +5,7 @@ import smithy4s.example.import_test.OpOutput import smithy4s.Schema import smithy4s.schema.Schema.unit import smithy4s.kinds.PolyFunction5 +import smithy4s.ShapeId import smithy4s.Service import smithy4s.ShapeTag import smithy4s.schema.Schema.bijection @@ -15,8 +16,6 @@ import smithy4s.Hints import smithy4s.StreamingSchema import smithy4s.kinds.FunctorAlgebra import smithy4s.capability.Transformation -import smithy4s.ShapeId -import smithy4s.Endpoint trait ImportServiceGen[F[_, _, _, _, _]] { self => @@ -26,7 +25,7 @@ trait ImportServiceGen[F[_, _, _, _, _]] { def transform : Transformation.PartiallyApplied[ImportServiceGen[F]] = new Transformation.PartiallyApplied[ImportServiceGen[F]](this) } -object ImportServiceGen extends Service[ImportServiceGen, ImportServiceOperation] { +object ImportServiceGen extends Service.Mixin[ImportServiceGen, ImportServiceOperation] { def apply[F[_]](implicit F: FunctorAlgebra[ImportServiceGen, F]): F.type = F @@ -36,7 +35,7 @@ object ImportServiceGen extends Service[ImportServiceGen, ImportServiceOperation alloy.SimpleRestJson(), ) - val endpoints: List[Endpoint[ImportServiceOperation, _, _, _, _, _]] = List( + val endpoints: List[ImportServiceGen.Endpoint[_, _, _, _, _]] = List( ImportOperation, ) @@ -63,7 +62,7 @@ object ImportServiceGen extends Service[ImportServiceGen, ImportServiceOperation } } case class ImportOperation() extends ImportServiceOperation[Unit, ImportServiceGen.ImportOperationError, OpOutput, Nothing, Nothing] - object ImportOperation extends Endpoint[ImportServiceOperation, Unit, ImportServiceGen.ImportOperationError, OpOutput, Nothing, Nothing] with Errorable[ImportOperationError] { + object ImportOperation extends ImportServiceGen.Endpoint[Unit, ImportServiceGen.ImportOperationError, OpOutput, Nothing, Nothing] with Errorable[ImportOperationError] { val id: ShapeId = ShapeId("smithy4s.example.import_test", "ImportOperation") val input: Schema[Unit] = unit.addHints(smithy4s.internals.InputOutput.Input.widen) val output: Schema[OpOutput] = OpOutput.schema.addHints(smithy4s.internals.InputOutput.Output.widen) diff --git a/modules/example/src/smithy4s/example/imp/package.scala b/modules/example/src/smithy4s/example/imp/package.scala index c220e0d78..54f51ce22 100644 --- a/modules/example/src/smithy4s/example/imp/package.scala +++ b/modules/example/src/smithy4s/example/imp/package.scala @@ -2,9 +2,9 @@ package smithy4s.example package object imp { type ImportService[F[_]] = smithy4s.kinds.FunctorAlgebra[ImportServiceGen, F] - object ImportService extends smithy4s.Service.Provider[ImportServiceGen, ImportServiceOperation] { + object ImportService extends smithy4s.Service.Provider[ImportServiceGen] { def apply[F[_]](implicit F: ImportService[F]): F.type = F - def service: smithy4s.Service[ImportServiceGen, ImportServiceOperation] = ImportServiceGen + def service: smithy4s.Service[ImportServiceGen] = ImportServiceGen val id: smithy4s.ShapeId = service.id } diff --git a/modules/example/src/smithy4s/example/package.scala b/modules/example/src/smithy4s/example/package.scala index 17252024c..1536040a7 100644 --- a/modules/example/src/smithy4s/example/package.scala +++ b/modules/example/src/smithy4s/example/package.scala @@ -2,33 +2,33 @@ package smithy4s package object example { type StreamedObjects[F[_]] = smithy4s.kinds.FunctorAlgebra[StreamedObjectsGen, F] - object StreamedObjects extends smithy4s.Service.Provider[StreamedObjectsGen, StreamedObjectsOperation] { + object StreamedObjects extends smithy4s.Service.Provider[StreamedObjectsGen] { def apply[F[_]](implicit F: StreamedObjects[F]): F.type = F - def service: smithy4s.Service[StreamedObjectsGen, StreamedObjectsOperation] = StreamedObjectsGen + def service: smithy4s.Service[StreamedObjectsGen] = StreamedObjectsGen val id: smithy4s.ShapeId = service.id } type FooService[F[_]] = smithy4s.kinds.FunctorAlgebra[FooServiceGen, F] - object FooService extends smithy4s.Service.Provider[FooServiceGen, FooServiceOperation] { + object FooService extends smithy4s.Service.Provider[FooServiceGen] { def apply[F[_]](implicit F: FooService[F]): F.type = F - def service: smithy4s.Service[FooServiceGen, FooServiceOperation] = FooServiceGen + def service: smithy4s.Service[FooServiceGen] = FooServiceGen val id: smithy4s.ShapeId = service.id } type BrandService[F[_]] = smithy4s.kinds.FunctorAlgebra[BrandServiceGen, F] - object BrandService extends smithy4s.Service.Provider[BrandServiceGen, BrandServiceOperation] { + object BrandService extends smithy4s.Service.Provider[BrandServiceGen] { def apply[F[_]](implicit F: BrandService[F]): F.type = F - def service: smithy4s.Service[BrandServiceGen, BrandServiceOperation] = BrandServiceGen + def service: smithy4s.Service[BrandServiceGen] = BrandServiceGen val id: smithy4s.ShapeId = service.id } type ObjectService[F[_]] = smithy4s.kinds.FunctorAlgebra[ObjectServiceGen, F] - object ObjectService extends smithy4s.Service.Provider[ObjectServiceGen, ObjectServiceOperation] { + object ObjectService extends smithy4s.Service.Provider[ObjectServiceGen] { def apply[F[_]](implicit F: ObjectService[F]): F.type = F - def service: smithy4s.Service[ObjectServiceGen, ObjectServiceOperation] = ObjectServiceGen + def service: smithy4s.Service[ObjectServiceGen] = ObjectServiceGen val id: smithy4s.ShapeId = service.id } type NameCollision[F[_]] = smithy4s.kinds.FunctorAlgebra[NameCollisionGen, F] - object NameCollision extends smithy4s.Service.Provider[NameCollisionGen, NameCollisionOperation] { + object NameCollision extends smithy4s.Service.Provider[NameCollisionGen] { def apply[F[_]](implicit F: NameCollision[F]): F.type = F - def service: smithy4s.Service[NameCollisionGen, NameCollisionOperation] = NameCollisionGen + def service: smithy4s.Service[NameCollisionGen] = NameCollisionGen val id: smithy4s.ShapeId = service.id } From fb989b03459108192900a7f0168b544cc79833c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 12:46:49 +0100 Subject: [PATCH 10/21] Fix .scalafmt.conf --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 0c26abfb8..b358249fd 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -2,7 +2,7 @@ version = "3.1.2" runner.dialect = scala213 project { excludePaths = [ - "glob:**/core/src-*/generated/*.scala", + "glob:**/core/src-*/generated/**/*.scala", "glob:**/example/src/smithy4s/**/*.scala", "glob:**/schematic-core/src/generated/*.scala", "glob:**/schematic-scalacheck/src/generated/*.scala" From 24cbff6c9682b7ee2d27d814137b0c26eabf9884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 12:55:59 +0100 Subject: [PATCH 11/21] Fix compliance tests --- .../compliancetests/ClientHttpComplianceTestCase.scala | 1 - .../compliancetests/ServerHttpComplianceTestCase.scala | 7 +++---- modules/core/src-2/generated/kinds/functorK.scala | 6 +++--- modules/core/src-2/generated/kinds/kinds.scala | 6 +++--- project/Boilerplate.scala | 6 +++--- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala b/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala index 6e6ec6c06..e0574aa55 100644 --- a/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala +++ b/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala @@ -33,7 +33,6 @@ import smithy.test._ import smithy4s.compliancetests.ComplianceTest.ComplianceResult import smithy4s.http.CodecAPI import smithy4s.Document -import smithy4s.Endpoint import smithy4s.http.PayloadError import smithy4s.Service import smithy4s.ShapeTag diff --git a/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala b/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala index ce05726ad..a26f3123b 100644 --- a/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala +++ b/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala @@ -25,7 +25,6 @@ import org.http4s._ import org.http4s.headers.`Content-Type` import smithy.test._ import smithy4s.Document -import smithy4s.Endpoint import smithy4s.http.CodecAPI import smithy4s.Service import smithy4s.ShapeTag @@ -235,7 +234,7 @@ abstract class ServerHttpComplianceTestCase[ ): (Service.Reflective[NoInputOp], Request[IO]) = { val amendedEndpoint = // format: off - new Endpoint[NoInputOp, Unit, E, O, Nothing, Nothing] { + new smithy4s.Endpoint[NoInputOp, Unit, E, O, Nothing, Nothing] { def hints: smithy4s.Hints = { val newHttp = smithy.api.Http( method = smithy.api.NonEmptyString("GET"), @@ -262,8 +261,8 @@ abstract class ServerHttpComplianceTestCase[ // format: off new Service.Reflective[NoInputOp] { override def id: ShapeId = ShapeId("custom", "service") - override def endpoints: List[Endpoint[NoInputOp, _, _, _, _, _]] = List(amendedEndpoint) - override def endpoint[I_, E_, O_, SI_, SO_](op: NoInputOp[I_, E_, O_, SI_, SO_]): (I_, Endpoint[NoInputOp, I_, E_, O_, SI_, SO_]) = ??? + override def endpoints: List[Endpoint[_, _, _, _, _]] = List(amendedEndpoint) + override def endpoint[I_, E_, O_, SI_, SO_](op: NoInputOp[I_, E_, O_, SI_, SO_]): (I_, Endpoint[I_, E_, O_, SI_, SO_]) = ??? override def version: String = originalService.version override def hints: Hints = originalService.hints } diff --git a/modules/core/src-2/generated/kinds/functorK.scala b/modules/core/src-2/generated/kinds/functorK.scala index 9d50fbf59..891f28e36 100644 --- a/modules/core/src-2/generated/kinds/functorK.scala +++ b/modules/core/src-2/generated/kinds/functorK.scala @@ -19,7 +19,7 @@ package smithy4s package kinds -trait FunctorK[Alg[_[_]]]{ +trait FunctorK[Alg[_[_]]] { def mapK[F[_], G[_]](alg: Alg[F], function: PolyFunction[F, G]): Alg[G] } object FunctorK { @@ -30,7 +30,7 @@ object FunctorK { } } -trait FunctorK2[Alg[_[_, _]]]{ +trait FunctorK2[Alg[_[_, _]]] { def mapK2[F[_, _], G[_, _]](alg: Alg[F], function: PolyFunction2[F, G]): Alg[G] } object FunctorK2 { @@ -41,7 +41,7 @@ object FunctorK2 { } } -trait FunctorK5[Alg[_[_, _, _, _, _]]]{ +trait FunctorK5[Alg[_[_, _, _, _, _]]] { def mapK5[F[_, _, _, _, _], G[_, _, _, _, _]](alg: Alg[F], function: PolyFunction5[F, G]): Alg[G] } object FunctorK5 { diff --git a/modules/core/src-2/generated/kinds/kinds.scala b/modules/core/src-2/generated/kinds/kinds.scala index a42aae821..b00ea2319 100644 --- a/modules/core/src-2/generated/kinds/kinds.scala +++ b/modules/core/src-2/generated/kinds/kinds.scala @@ -19,17 +19,17 @@ package smithy4s package kinds -object Kind1{ +object Kind1 { type Existential[F[_]] = F[_] @inline def existential[F[_], A0](fa: F[A0]): F[_] = fa.asInstanceOf[F[_]] } -object Kind2{ +object Kind2 { type Existential[F[_, _]] = F[_, _] @inline def existential[F[_, _], A0, A1](fa: F[A0, A1]): F[_, _] = fa.asInstanceOf[F[_, _]] } -object Kind5{ +object Kind5 { type Existential[F[_, _, _, _, _]] = F[_, _, _, _, _] @inline def existential[F[_, _, _, _, _], A0, A1, A2, A3, A4](fa: F[A0, A1, A2, A3, A4]): F[_, _, _, _, _] = fa.asInstanceOf[F[_, _, _, _, _]] } diff --git a/project/Boilerplate.scala b/project/Boilerplate.scala index 534aa0326..2934082da 100644 --- a/project/Boilerplate.scala +++ b/project/Boilerplate.scala @@ -283,7 +283,7 @@ object Boilerplate { |package smithy4s |package kinds | - -trait FunctorK$suffix[Alg[_[${`_.._`}]]]{ + -trait FunctorK$suffix[Alg[_[${`_.._`}]]] { - def mapK$suffix[F[${`_.._`}], G[${`_.._`}]](alg: Alg[F], function: PolyFunction$suffix[F, G]): Alg[G] -} -object FunctorK$suffix { @@ -311,7 +311,7 @@ object Boilerplate { |package smithy4s |package kinds | - -object Kind$arity{ + -object Kind$arity { - type Existential[+F[${`_.._`}]] <: (Any { type T }) - inline def existential[F[${`_.._`}], ${`A..N`}](fa: F[${`A..N`}]): Existential[F] = fa.asInstanceOf[Existential[F]] -} @@ -333,7 +333,7 @@ object Boilerplate { |package smithy4s |package kinds | - -object Kind$arity{ + -object Kind$arity { - type Existential[F[${`_.._`}]] = F[${`_.._`}] - @inline def existential[F[${`_.._`}], ${`A..N`}](fa: F[${`A..N`}]): F[${`_.._`}] = fa.asInstanceOf[F[${`_.._`}]] -} From 6b33083b66c5bd17eb785d58953372ceb148f04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 13:08:28 +0100 Subject: [PATCH 12/21] Fix compliance tests (on Scala 3) --- .../ClientHttpComplianceTestCase.scala | 2 +- .../ServerHttpComplianceTestCase.scala | 2 +- .../core/src-3/generated/kinds/functorK.scala | 52 +++++-------------- .../core/src-3/generated/kinds/kinds.scala | 10 ++-- 4 files changed, 19 insertions(+), 47 deletions(-) diff --git a/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala b/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala index e0574aa55..fc3795e5b 100644 --- a/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala +++ b/modules/compliance-tests/src/smithy4s/compliancetests/ClientHttpComplianceTestCase.scala @@ -57,7 +57,7 @@ abstract class ClientHttpComplianceTestCase[ import ce._ import org.http4s.implicits._ private val baseUri = uri"http://localhost/" - private val service = serviceProvider.service + private[compliancetests] val service = serviceProvider.service def getClient(app: HttpApp[IO]): Resource[IO, FunctorAlgebra[Alg, IO]] def codecs: CodecAPI diff --git a/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala b/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala index a26f3123b..e8b7bcbe9 100644 --- a/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala +++ b/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala @@ -47,7 +47,7 @@ abstract class ServerHttpComplianceTestCase[ ) { import ce._ import org.http4s.implicits._ - private val originalService = serviceProvider.service + private[compliancetests] val originalService = serviceProvider.service private val baseUri = uri"http://localhost/" def getServer[Alg2[_[_, _, _, _, _]]]( diff --git a/modules/core/src-3/generated/kinds/functorK.scala b/modules/core/src-3/generated/kinds/functorK.scala index 0471e5baf..eeed91903 100644 --- a/modules/core/src-3/generated/kinds/functorK.scala +++ b/modules/core/src-3/generated/kinds/functorK.scala @@ -23,55 +23,31 @@ trait FunctorK[Alg[_[_]]] { def mapK[F[_], G[_]](alg: Alg[F], function: PolyFunction[F, G]): Alg[G] } object FunctorK { - inline def apply[Alg[_[_]]](implicit ev: FunctorK[Alg]): FunctorK[Alg] = ev + inline def apply[Alg[_[_]]](implicit ev: FunctorK[Alg]) : FunctorK[Alg] = ev - implicit def polyfunctionFunctorK[F[_]] - : FunctorK[[G[_]] =>> PolyFunction[F, G]] = - new FunctorK[[G[_]] =>> PolyFunction[F, G]] { - def mapK[G[_], H[_]]( - fa: PolyFunction[F, G], - fk: PolyFunction[G, H] - ): PolyFunction[F, H] = fa.andThen(fk) - } + implicit def polyfunctionFunctorK[F[_]]: FunctorK[[G[_]] =>> PolyFunction[F, G]] = new FunctorK[[G[_]] =>> PolyFunction[F, G]] { + def mapK[G[_], H[_]](fa: PolyFunction[F, G], fk: PolyFunction[G, H]): PolyFunction[F, H] = fa.andThen(fk) + } } trait FunctorK2[Alg[_[_, _]]] { - def mapK2[F[_, _], G[_, _]]( - alg: Alg[F], - function: PolyFunction2[F, G] - ): Alg[G] + def mapK2[F[_, _], G[_, _]](alg: Alg[F], function: PolyFunction2[F, G]): Alg[G] } object FunctorK2 { - inline def apply[Alg[_[_, _]]](implicit ev: FunctorK2[Alg]): FunctorK2[Alg] = - ev + inline def apply[Alg[_[_, _]]](implicit ev: FunctorK2[Alg]) : FunctorK2[Alg] = ev - implicit def polyfunctionFunctorK2[F[_, _]] - : FunctorK2[[G[_, _]] =>> PolyFunction2[F, G]] = - new FunctorK2[[G[_, _]] =>> PolyFunction2[F, G]] { - def mapK2[G[_, _], H[_, _]]( - fa: PolyFunction2[F, G], - fk: PolyFunction2[G, H] - ): PolyFunction2[F, H] = fa.andThen(fk) - } + implicit def polyfunctionFunctorK2[F[_, _]]: FunctorK2[[G[_, _]] =>> PolyFunction2[F, G]] = new FunctorK2[[G[_, _]] =>> PolyFunction2[F, G]] { + def mapK2[G[_, _], H[_, _]](fa: PolyFunction2[F, G], fk: PolyFunction2[G, H]): PolyFunction2[F, H] = fa.andThen(fk) + } } trait FunctorK5[Alg[_[_, _, _, _, _]]] { - def mapK5[F[_, _, _, _, _], G[_, _, _, _, _]]( - alg: Alg[F], - function: PolyFunction5[F, G] - ): Alg[G] + def mapK5[F[_, _, _, _, _], G[_, _, _, _, _]](alg: Alg[F], function: PolyFunction5[F, G]): Alg[G] } object FunctorK5 { - inline def apply[Alg[_[_, _, _, _, _]]](implicit - ev: FunctorK5[Alg] - ): FunctorK5[Alg] = ev + inline def apply[Alg[_[_, _, _, _, _]]](implicit ev: FunctorK5[Alg]) : FunctorK5[Alg] = ev - implicit def polyfunctionFunctorK5[F[_, _, _, _, _]] - : FunctorK5[[G[_, _, _, _, _]] =>> PolyFunction5[F, G]] = - new FunctorK5[[G[_, _, _, _, _]] =>> PolyFunction5[F, G]] { - def mapK5[G[_, _, _, _, _], H[_, _, _, _, _]]( - fa: PolyFunction5[F, G], - fk: PolyFunction5[G, H] - ): PolyFunction5[F, H] = fa.andThen(fk) - } + implicit def polyfunctionFunctorK5[F[_, _, _, _, _]]: FunctorK5[[G[_, _, _, _, _]] =>> PolyFunction5[F, G]] = new FunctorK5[[G[_, _, _, _, _]] =>> PolyFunction5[F, G]] { + def mapK5[G[_, _, _, _, _], H[_, _, _, _, _]](fa: PolyFunction5[F, G], fk: PolyFunction5[G, H]): PolyFunction5[F, H] = fa.andThen(fk) + } } diff --git a/modules/core/src-3/generated/kinds/kinds.scala b/modules/core/src-3/generated/kinds/kinds.scala index 9945bbc82..3e4fd6d25 100644 --- a/modules/core/src-3/generated/kinds/kinds.scala +++ b/modules/core/src-3/generated/kinds/kinds.scala @@ -21,19 +21,15 @@ package kinds object Kind1 { type Existential[+F[_]] <: (Any { type T }) - inline def existential[F[_], A0](fa: F[A0]): Existential[F] = - fa.asInstanceOf[Existential[F]] + inline def existential[F[_], A0](fa: F[A0]): Existential[F] = fa.asInstanceOf[Existential[F]] } object Kind2 { type Existential[+F[_, _]] <: (Any { type T }) - inline def existential[F[_, _], A0, A1](fa: F[A0, A1]): Existential[F] = - fa.asInstanceOf[Existential[F]] + inline def existential[F[_, _], A0, A1](fa: F[A0, A1]): Existential[F] = fa.asInstanceOf[Existential[F]] } object Kind5 { type Existential[+F[_, _, _, _, _]] <: (Any { type T }) - inline def existential[F[_, _, _, _, _], A0, A1, A2, A3, A4]( - fa: F[A0, A1, A2, A3, A4] - ): Existential[F] = fa.asInstanceOf[Existential[F]] + inline def existential[F[_, _, _, _, _], A0, A1, A2, A3, A4](fa: F[A0, A1, A2, A3, A4]): Existential[F] = fa.asInstanceOf[Existential[F]] } From 4218b6962138b451d90eff2f26e47e58411e2fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 13:15:48 +0100 Subject: [PATCH 13/21] Fix compliance-tests (2.12) --- .scalafmt.conf | 4 +--- .../compliancetests/ServerHttpComplianceTestCase.scala | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index b358249fd..a6becffc1 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -2,10 +2,8 @@ version = "3.1.2" runner.dialect = scala213 project { excludePaths = [ - "glob:**/core/src-*/generated/**/*.scala", + "glob:**/core/src*/generated/**/*.scala", "glob:**/example/src/smithy4s/**/*.scala", - "glob:**/schematic-core/src/generated/*.scala", - "glob:**/schematic-scalacheck/src/generated/*.scala" ] } docstrings.style = keep diff --git a/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala b/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala index e8b7bcbe9..b9ffc3bc2 100644 --- a/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala +++ b/modules/compliance-tests/src/smithy4s/compliancetests/ServerHttpComplianceTestCase.scala @@ -117,7 +117,7 @@ abstract class ServerHttpComplianceTestCase[ run = { deferred[I].flatMap { inputDeferred => val fakeImpl: FunctorAlgebra[Alg, IO] = - originalService.fromPolyFunction( + originalService.fromPolyFunction[Kind1[IO]#toKind5]( new originalService.FunctorInterpreter[IO] { def apply[I_, E_, O_, SE_, SO_]( op: originalService.Operation[I_, E_, O_, SE_, SO_] From bf365225ef3026db898f6123f51333bb94595bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 14:03:30 +0100 Subject: [PATCH 14/21] Remove unused import --- modules/aws/src/smithy4s/aws/AwsClient.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/aws/src/smithy4s/aws/AwsClient.scala b/modules/aws/src/smithy4s/aws/AwsClient.scala index dd00ea969..1dde4b964 100644 --- a/modules/aws/src/smithy4s/aws/AwsClient.scala +++ b/modules/aws/src/smithy4s/aws/AwsClient.scala @@ -21,7 +21,6 @@ import cats.effect.Resource import cats.syntax.all._ import internals.AwsJsonRPCInterpreter -import smithy4s.kinds.PolyFunction5 object AwsClient { From e2ff93c183da4fecbb479bd4f01c7a855ffa04d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 17:08:37 +0100 Subject: [PATCH 15/21] Attempting to fix flaky test --- .../dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala b/modules/dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala index 51d10018c..2a8d97bd4 100644 --- a/modules/dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala +++ b/modules/dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala @@ -44,7 +44,7 @@ private[dynamic] trait PlatformUtils { self: Utils.type => SModel .assembler() .addImport(s"./sampleSpecs/$fileName") - .discoverModels() + .discoverModels(this.getClass().getClassLoader()) .assemble() .unwrap() ) From 20e2a19820d1ea4e63db7c72761583d859a2f4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 22:58:20 +0100 Subject: [PATCH 16/21] Try disabling jar cache --- build.sbt | 3 --- .../dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 1f222cddd..9958448f0 100644 --- a/build.sbt +++ b/build.sbt @@ -531,9 +531,6 @@ lazy val dynamic = projectMatrix .dependsOn(core % "test->test;compile->compile", testUtils % "test->compile") .settings( genDiscoverModels := true, - allowedNamespaces := Seq( - "smithy4s.dynamic.model" - ), libraryDependencies ++= Seq( "org.scala-lang.modules" %%% "scala-collection-compat" % "2.8.1", Dependencies.Cats.core.value diff --git a/modules/dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala b/modules/dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala index 2a8d97bd4..b51ae2230 100644 --- a/modules/dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala +++ b/modules/dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala @@ -45,6 +45,7 @@ private[dynamic] trait PlatformUtils { self: Utils.type => .assembler() .addImport(s"./sampleSpecs/$fileName") .discoverModels(this.getClass().getClassLoader()) + .putProperty(ModelAssembler.DISABLE_JAR_CACHE, true) .assemble() .unwrap() ) From dbe71dad148c513cc96096c03381b57adc1fff97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 23:13:40 +0100 Subject: [PATCH 17/21] Trying with fork ? --- build.sbt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 9958448f0..9a4f664d5 100644 --- a/build.sbt +++ b/build.sbt @@ -615,7 +615,9 @@ lazy val http4s = projectMatrix if (virtualAxes.value.contains(CatsEffect2Axis)) moduleName.value + "-ce2" else moduleName.value - } + }, + Test / fork := virtualAxes.value.contains(VirtualAxis.jvm), + Test / javaOptions += s"-Duser.dir=${sys.props("user.dir")}" ) .http4sPlatform(allJvmScalaVersions, jvmDimSettings) From 6dbfe781c009592439c9021bb8ac038edaf33fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 23:21:06 +0100 Subject: [PATCH 18/21] Whaaaat ? --- .../dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala b/modules/dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala index b51ae2230..691164313 100644 --- a/modules/dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala +++ b/modules/dynamic/test/src-jvm/smithy4s/dynamic/PlatformUtils.scala @@ -17,6 +17,7 @@ package smithy4s.dynamic import software.amazon.smithy.model.{Model => SModel} +import software.amazon.smithy.model.loader.ModelAssembler import cats.syntax.all._ import DummyIO._ From 15a7db841e3d5ef9c2fca598712fb711c739871e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 3 Nov 2022 23:25:52 +0100 Subject: [PATCH 19/21] Fix aws-http4s --- modules/aws-http4s/src/smithy4s/aws/http4s/package.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/aws-http4s/src/smithy4s/aws/http4s/package.scala b/modules/aws-http4s/src/smithy4s/aws/http4s/package.scala index 9d306c0c4..fde5cce4f 100644 --- a/modules/aws-http4s/src/smithy4s/aws/http4s/package.scala +++ b/modules/aws-http4s/src/smithy4s/aws/http4s/package.scala @@ -23,8 +23,8 @@ import org.http4s.client.Client package object http4s { - implicit final class ServiceOps[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _]]( - private[this] val serviceProvider: smithy4s.Service.Provider[Alg, Op] + implicit final class ServiceOps[Alg[_[_, _, _, _, _]]]( + private[this] val serviceProvider: smithy4s.Service.Provider[Alg] ) { def awsClient[F[_]: Temporal]( From 548650f459bf27ba97f45ae54ae3e24653426eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Wed, 9 Nov 2022 09:53:45 +0100 Subject: [PATCH 20/21] cleanup --- build.sbt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index bcb2c7229..9cdb80646 100644 --- a/build.sbt +++ b/build.sbt @@ -610,9 +610,7 @@ lazy val http4s = projectMatrix if (virtualAxes.value.contains(CatsEffect2Axis)) moduleName.value + "-ce2" else moduleName.value - }, - Test / fork := virtualAxes.value.contains(VirtualAxis.jvm), - Test / javaOptions += s"-Duser.dir=${sys.props("user.dir")}" + } ) .http4sPlatform(allJvmScalaVersions, jvmDimSettings) From f23ff216688961a2fbc4da49f4f00db3ffc7a3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Wed, 9 Nov 2022 11:13:04 +0100 Subject: [PATCH 21/21] Fix docs --- modules/docs/src/03-protocols/05-compliance-tests.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/docs/src/03-protocols/05-compliance-tests.md b/modules/docs/src/03-protocols/05-compliance-tests.md index d1b9fa3fa..730733dfd 100644 --- a/modules/docs/src/03-protocols/05-compliance-tests.md +++ b/modules/docs/src/03-protocols/05-compliance-tests.md @@ -109,9 +109,9 @@ Then, you can create and instance of `ClientHttpComplianceTestCase` and/or `Serv val clientTestGenerator = new ClientHttpComplianceTestCase[ alloy.SimpleRestJson, HelloWorldServiceGen, - HelloWorldServiceOperation ]( - alloy.SimpleRestJson() + alloy.SimpleRestJson(), + HelloWorldService ) { import org.http4s.implicits._ private val baseUri = uri"http://localhost/" @@ -126,13 +126,13 @@ val clientTestGenerator = new ClientHttpComplianceTestCase[ val serverTestGenerator = new ServerHttpComplianceTestCase[ alloy.SimpleRestJson, HelloWorldServiceGen, - HelloWorldServiceOperation ]( - alloy.SimpleRestJson() + alloy.SimpleRestJson(), + HelloWorldService ) { - def getServer[Alg2[_[_, _, _, _, _]], Op2[_, _, _, _, _]]( + def getServer[Alg2[_[_, _, _, _, _]]]( impl: smithy4s.kinds.FunctorAlgebra[Alg2, IO] - )(implicit s: Service[Alg2, Op2]): Resource[IO, HttpRoutes[IO]] = + )(implicit s: Service[Alg2]): Resource[IO, HttpRoutes[IO]] = SimpleRestJsonBuilder(s).routes(impl).resource def codecs = SimpleRestJsonBuilder.codecs }