argonaut-io/argonaut

Override mapJson in CodecJson

enzief opened this issue · 2 comments

Does it make sense to

sealed abstract class CodecJson[A] ... {
  override def mapJson(f: Json => Json): CodecJson[A] =
    CodecJson.derived(
      Encoder.mapJson(f),
      Decoder
    )
}

?

Surely it would need an inverse for the decoder?

Right. As there's no contramapJson for Decoder would it be correct to add

trait Decoder[A] {
  def contramapJson(f: Json => Json): Decoder[A] // not sure about this signature
}

abstract class CodecJson[A] {
  def xmapJson(f: Json => Json): CodecJson[A]
}