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

Enhancement/2025 01 make decoder support either #350

Merged
merged 13 commits into from
Jan 2, 2025

Conversation

takapi327
Copy link
Owner

@takapi327 takapi327 commented Jan 1, 2025

Implementation Details

Modified to allow Either to be used during Decoder construction.

This allows us to construct a process for cases that do not match the following pattern

enum Status(val code: Int):
  case InActive extends Status(0)
  case Active extends Status(1)

given Decoder[Status] = Decoder[Int].emap {
  case 0 => Right(Status.InActive)
  case 1 => Right(Status.Active)
  case unknown => Left(s"$unknown is Unknown Status code")
}

This modification allows Codec to use Either for construction.

given Codec[Status] = Codec[Int].eimap {
  case 0 => Right(Status.InActive)
  case 1 => Right(Status.Active)
  case unknown => Left(s"$unknown is Unknown Status code")
}(_.code)

Pull Request Checklist

  • Wrote unit and integration tests
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code formatting by scalafmt (sbt scalafmtAll command execution)
  • Add copyright headers to new files

References

@takapi327 takapi327 added 💪 enhancement Functional enhancement project:dsl Addition and modification of functionality to DSL projects labels Jan 1, 2025
@takapi327 takapi327 added this to the 0.3.0 milestone Jan 1, 2025
@takapi327 takapi327 self-assigned this Jan 1, 2025
@takapi327 takapi327 merged commit cb32ef0 into master Jan 2, 2025
27 checks passed
@takapi327 takapi327 deleted the enhancement/2025-01-Make-Decoder-support-Either branch January 2, 2025 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement Functional enhancement project:dsl Addition and modification of functionality to DSL projects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant