FawnEncoder
Much like the circe
Encoder
interface, this assumes encoding cannot fail, and since SQS usually deals in strings, we expect a string output.
trait FawnEncoder[T] {
def encode(t: T): String
}
This provides a cats Contravariant
so encoders have contramap
and other useful methods available:
val longEncoder: FawnEncoder[Long] = new FawnEncoder[Long] {
def encode(l: Long) = l.toString
}
// longEncoder: FawnEncoder[Long] = repl.MdocSession$App0$$anon$1@3b7b3e73
val intEncoder: FawnEncoder[Int] = longEncoder.contramap(_.toLong)
// intEncoder: FawnEncoder[Int] = com.meltwater.fawn.codec.FawnEncoder$$anon$1$$Lambda$7018/433883080@757850d8