Idea: `Lift`
See original GitHub issueHi and thanks for this library!
It would be nice to have a lift
function in the library that ensures a value T is a Maybe<T>, without creating a Maybe<Maybe<T>>:
lift<T>(a: T | Maybe<T>): Maybe<T> {
return Maybe.isInstance( value )
? value
: Maybe.of( value )
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
IdeaLift | Mindfulness and Organizational Consulting
All of IdeaLift's programs are customized and designed to meet your organization's needs, whichever focus area is involved. We will help you get...
Read more >LIFT - IntelliJ IDEs Plugin - JetBrains Marketplace
This plugin allows novice programmers to run a Java program with command-line arguments by typing the arguments in a simple popup window.
Read more >53 Lift hoist ideas | homemade tools, lifts & ... - Pinterest
Jan 21, 2018 - Explore Helen Thomas's board "Lift hoist ideas" on Pinterest. See more ideas about homemade tools, lifts & hoists, metal...
Read more >What the science says about lifting mask mandates - Nature
Although there's been no formal study on the effectiveness of mask marketing, the idea might not be far-fetched. Instructions for creating fun ...
Read more >Hello World in Java (Windows) - LIFT-CS
The installer installs and configures a Java programming environment, including OpenJDK 11 and IntelliJ IDEA Community Edition 2022.2.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve chewed on this for a while, and given both @bmakuh’s astute comment and my own reflections on it, I’m going to close it and not implement. That said: I appreciate the thoughtful suggestion, and I hope the library continues to be useful for you!
Following up on this, I realized for the points you both just raised that we definitely wouldn’t want to change the behavior of
of
. I’m also inclined to say that because this is kind of an edge case, it doesn’t make sense to push handling for it into the library, especially since it’s straightforward to work around or to useandThen
/flatMap
to resolve the nesting. Mostly because we’re trying to walk a fine line of being idiomatic to use in TypeScript, with the assumption that we have the type checker around to help, and therefore with the most minimal set of runtime checks possible (shoving as much as possible into the type system).