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

Create feature flag for enabling expandPartialFromOptionToNonOption #322

Closed
olivierdeckers opened this issue Jun 26, 2023 · 1 comment · Fixed by #477
Closed

Create feature flag for enabling expandPartialFromOptionToNonOption #322

olivierdeckers opened this issue Jun 26, 2023 · 1 comment · Fixed by #477
Labels
breaking change Change resulting in compilation errors of code that used to be considered correct, or linking errors enhancement

Comments

@olivierdeckers
Copy link

TLDR: The user should explicitly enable a feature flag to enable derivation using expandPartialFromOptionToNonOption.

In the current situation, a user has two options:

  • use Transformer, the transformation cannot fail (in a way where problems are aggregated)
  • use PartialTransformer, transformation can fail and problems are aggregated. However, Option[T] -> T partial transformer is derived automatically, so no compilation error if this is not what the user meant.

It would be nice to have some middle ground, where if we don't explicitly enable a feature flag, the following results in a compilation error:

val x: Option[T] = None
...
val y = x.transformIntoPartial[T].asEither // Left(empty)

This may seem obvious in a simple example, but in more complicated code while refactoring if let's say x is changed from T to Option[T], the compiler no longer makes you think about maybe y should be Option[T] as well.

@MateuszKubuszok MateuszKubuszok added the breaking change Change resulting in compilation errors of code that used to be considered correct, or linking errors label Sep 30, 2023
@MateuszKubuszok MateuszKubuszok linked a pull request Mar 22, 2024 that will close this issue
3 tasks
@MateuszKubuszok
Copy link
Member

I added the flag allowing to disable the behavior, however I do not intend to make that behavor disabled by default as it would make Partials to much PITA to use most of the time. I explained my reasons in #477 in more details. The flag is released and available since 1.0.0-M2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Change resulting in compilation errors of code that used to be considered correct, or linking errors enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants