This file contains hidden or 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
Decoder[FailedMessage].inj[Messages] |
This file contains hidden or 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
implicit class InjectableFunctor[F[_], A](fa: F[A]) { | |
def inj[B](implicit F: Functor[F], I: Inject[A, B]): F[B] = { | |
fa.map(I.inj) | |
} | |
} |
This file contains hidden or 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
Decoder[FailureResponse].map(Inject[FailedResponse, Messages].inj) |
This file contains hidden or 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
Decoder[FailedResponse].map(m ⇒ Right(Left(m)) |
This file contains hidden or 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
type Messages = SuccessResposne :=: FailedResponse :+: QuotaRequest |
This file contains hidden or 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
type A = Int :+: String :+: Double | |
type B = (Int :+: (String :+: Double)) | |
type C = Either[Int, Either[String, Double]] | |
// A === B === C |
This file contains hidden or 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
type :+:[A, B] = Either[A, B] |
This file contains hidden or 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
abstract class Inject[A, B] { | |
def inj: A ⇒ B | |
def prj: B ⇒ Option[A] | |
} |
This file contains hidden or 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
import cats.Inject | |
type B = Either[Int, Either[String, Double]] | |
val i = Inject[Int, B].inj(1) // Left(1) | |
val s = Inject[String, B].inj("hi") // Right(Left(hi)) | |
val d = Inject[Double, B].inj(1.0) // Right(Right(1.0)) | |
Inject[String, B].prj(i) // None | |
Inject[String, B].prj(s) // Some(hi) |
This file contains hidden or 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
import io.circe.{Encoder, Decoder} | |
import cats.effect.Concurrent | |
import cats.syntax.either._ | |
case class JmsMessage[T](value: T, metadata: Metadata) | |
class JmsParentController[ | |
F[_] : Concurrent, | |
Request : Encoder, | |
SuccessResponse : Decoder, |