FSharpx.Extras icon indicating copy to clipboard operation
FSharpx.Extras copied to clipboard

This library has any null coalescing operator implementation?

Open Micha-kun opened this issue 5 years ago • 2 comments

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.

Micha-kun avatar Sep 15 '20 08:09 Micha-kun

@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?

gdziadkiewicz avatar Oct 24 '20 10:10 gdziadkiewicz

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.

Micha-kun avatar Oct 26 '20 16:10 Micha-kun