fsprojects / FSharpx.Extras

Functional programming and other utilities from the original "fsharpx" project
https://fsprojects.github.io/FSharpx.Extras/
The Unlicense
682 stars 146 forks source link

This library has any null coalescing operator implementation? #398

Open Micha-kun opened 3 years ago

Micha-kun commented 3 years ago

Looking at this StackOverflown solution (https://stackoverflow.com/questions/21194565/null-coalescing-operator-in-f), seems that people found a tricky way to "emulate" C# null coalescing operator into F#. It is implemented in this library or something similar? If not, it would be a great addition for the community.

gdziadkiewicz commented 3 years ago

@Micha-kun I don't see anything like that In FSharpx.Extras. Could you elaborate on what would you be willing to add? I checked out (visually, didn't run it) that https://ekonbenefits.github.io/FSharp.Interop.NullOptAble/ mentioned in one of the answers and it looks nice. How would our part in Fsharpx.Extras be different from that?

Micha-kun commented 3 years ago

Hmmm... It's hard to think what would different about this kind of operator... Thanks for sharing that library (I didn't look inside when was searching about this operator). I was only thinking in simple operators, not a full computation implementation around this problem. It would be perfect to integrate that library into this :D Edit: And checking this library code, we really don't need it's computation expressions, because this library it already has it's own option computation expression... we could refine our "maybe" computation expression making Nullable types compatible. And simply join the |?? (or |?->, or what would be perfect? |.? could be?) into our Nullable operator module.