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

fix nested maybes #13

Closed
wants to merge 1 commit into from
Closed

fix nested maybes #13

wants to merge 1 commit into from

Conversation

pravdomil
Copy link

fix billion-dollar mistake

This is a known limitation: using null as Nothing and identity as Just means that nesting two maybes squashes Just Nothing with Nothing

@miniBill
Copy link
Owner

miniBill commented Jul 2, 2022

This is a backwards-incompatible change. I could consider merging if you created a new function, but changing the existing one is not possible without breaking existing Codecs

@miniBill miniBill closed this Jul 2, 2022
@pravdomil
Copy link
Author

how the new function should be named?

@miniBill
Copy link
Owner

miniBill commented Jul 3, 2022

Eh... that's a tough call to be honest. The obvious maybe choice is already taken by the existing "collapsing/lenient/null" function.

I'm curious: why do you need a non-collapsing Maybe codec? The fact that you're using custom means that the format is not server-bound, so why not just creating a custom type better suited for your use case?

Like, in hindsight I should have probably called the function which is now maybe something like orNothing, or nullable or something, but the reason why I thought it was acceptable to collapse Just Nothing to Nothing is that... you should never have a Just Nothing in your model?

@pravdomil
Copy link
Author

you should never have a Just Nothing in your model

Well you should not have Just Nothing in your model, but you can, so it can happen.

means that the format is not server-bound

A server bound? I'm using Elm on server side.

function which is now maybe something like orNothing, or nullable or something

What about:

  • maybeWithoutNull
  • maybeCustomType
  • maybeType
  • customMaybe
  • justOrNothing
  • betterMaybe

This is a backwards-incompatible change.

Or better rename current function to maybeLegacy then create a new version.
Then create function maybe a create new version.
Since it is a major version change people are forced to upgrade manually.


BTW: this PR also fixes #9.

@pravdomil
Copy link
Author

I would choose customMaybe or maybeType? What do you think?

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

Successfully merging this pull request may close these issues.

None yet

2 participants