-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix algorithm to prevent recursive givens (#19411)
- Loading branch information
Showing
5 changed files
with
72 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
given ipEncoder[IP <: IpAddress]: Encoder[IP] = Encoder[String].contramap(_.toString) | ||
|
||
class Encoder[A] { | ||
final def contramap[B](f: B => A): Encoder[B] = new Encoder[B] | ||
} | ||
|
||
object Encoder { | ||
final def apply[A](implicit instance: Encoder[A]): Encoder[A] = instance | ||
implicit final val encodeString: Encoder[String] = new Encoder[String] | ||
} | ||
|
||
trait Json | ||
trait IpAddress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
trait GeneratedEnum | ||
trait Decoder[A] | ||
|
||
object Decoder: | ||
given Decoder[Int] = ??? | ||
|
||
object GeneratedEnumDecoder: | ||
|
||
given [A <: GeneratedEnum]: Decoder[A] = | ||
summon[Decoder[Int]] | ||
??? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
trait QueryParamDecoder[E]: | ||
def emap[T](fn: E => Either[Throwable, T]): QueryParamDecoder[T] | ||
object QueryParamDecoder: | ||
def apply[T](implicit ev: QueryParamDecoder[T]): QueryParamDecoder[T] = ev | ||
implicit lazy val stringQueryParamDecoder: QueryParamDecoder[String] = ??? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
given[E](using e: EnumOf[E]): QueryParamDecoder[E] = QueryParamDecoder[String].emap(_ => Right(???)) | ||
trait EnumOf[E] |