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

Use a value instead of undefined for prism failure #2

Open
SpencerPark opened this issue Jul 4, 2018 · 0 comments
Open

Use a value instead of undefined for prism failure #2

SpencerPark opened this issue Jul 4, 2018 · 0 comments

Comments

@SpencerPark
Copy link

I would like to start by saying really enjoy this library for it's simplicity and well written type signatures. Many of the other options that try to introduce fp optics include way too much overhead and stop feeling like typescript.

One issue I am running into is that my lenses often lookup data that may very well be undefined and that is not a failure in the prism sense but a perfectly valid value. Can we use a sentinel value (like Prism.FAIL) or similar to require get to explicitly state the intent to fail? This way Lens can still share all of the Prism constructors/composition/etc while still allowing undefined as a valid value. I am a huge fan of the type union approach over wrapping the result in optional or similar in Prism's get and so I think this must stay.

Mainly this breaks during composition but I've been putting together some utilities as well (like filter) that also run into this problem as they use Prismish so we lose the | undefined from the actual projection type.

I would be happy to submit a PR for this if you agree it is a worth-while breaking API change, as I do :)

SpencerPark added a commit to SpencerPark/lenses that referenced this issue Jul 8, 2018
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

1 participant