Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override mapJson in CodecJson #318

Open
enzief opened this issue Feb 19, 2019 · 2 comments
Open

Override mapJson in CodecJson #318

enzief opened this issue Feb 19, 2019 · 2 comments

Comments

@enzief
Copy link

enzief commented Feb 19, 2019

Does it make sense to

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

?

@seanparsons
Copy link
Member

Surely it would need an inverse for the decoder?

@enzief
Copy link
Author

enzief commented Feb 20, 2019

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]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants