So I've been getting annoyed with not having a packaged (if not standardized) null/option/nullable workflow.
So I decided to make a library. Naming is a bit challenging, clearly it's an F# only library, so FSharp.BlahBlah.Something. The only BlahBlah example wise that would make sense would be FSharp.Core ¯\_(ツ)_/¯, so I made it FSharp.Core.Experimental.OptionBuilder. I feel like that is dubious, but I'd like some feedback on what the second category of the name should be if otherwise.
The implementation of the actual OptionBuilder (option {}) is pretty much wrapping the Option module functions. I have Bind and ReturnFrom overloads for 'T option, 'T Nullable and 'T when 'T:null. I added Try/Finally/Using but didn't include any enumeration, it just didn't make sense for a reasonable work flow of something would return a single option type.
However, a null work flow for a collection of items was still desirable. So I made an addtional builder as part of this library. chooseSeq {}, which was substantially more complex. Similarly it has overloads for Bind and YieldFrom for 'T option, 'T Nullable and 'T when 'T:null. The results from yield are combined into a sequence when yield! is not None, Nullable or null. I also added YieldFrom overloads for 'T seq and string, that flatten sequences like just like seq {}, but I'm unsure if I've inadvertently caused any problems by doing this. Finally I made chooseSeq a delayed sequence, just like seq.
I'd be really interested in some feedback. Especially if I've went an incorrect direction naming wise.
The project is here:
I haven't put it on nuget mainly because of the name, however I have a myget feed:
Finally here are some examples that I've adapted from else where:
Thanks!
Jay Tuley