(This post has been edited 2019-04-23 to constrain/concretize the functions I'd like to be implemented.)
The ValueOption module now has feature parity with Option. That's great! But there's a lot of other functions in other modules that use Option, where ValueOption might provide better performance by avoiding unneeded allocations. I am primarily concerned with having ValueOption equivalents of the following functions:
List.choose / Seq.choose / Array.choose
List.pick / Seq.pick / Array.pick
List.tryPick / Seq.tryPick / Array.tryPick
List.unfold / Seq.unfold / Array.unfold
These are arguably the most useful to implement, since they (potentially) allocate one option object for each item. If further prioritization is needed, then I'd guess choose and tryPick are the most commonly used.
(For the sake of completeness: Additional functions in these modules that could be implemented too are all the tryX functions that return an option, but in this issue, I choose to concentrate only on the above.)
I might be able to submit a PR if I get some general guidance on what to add where (never contributed code to FSharp.Core before). For example, should I duplicate existing functions but use ValueSome/ValueNone, or should old functions delegate to new functions in some way, etc. (I suppose the performance will be best with completely separate definitions.) But I'm more than happy to let other people take it, too.
(This post has been edited 2019-04-23 to constrain/concretize the functions I'd like to be implemented.)
The
ValueOptionmodule now has feature parity withOption. That's great! But there's a lot of other functions in other modules that useOption, whereValueOptionmight provide better performance by avoiding unneeded allocations. I am primarily concerned with havingValueOptionequivalents of the following functions:List.choose/Seq.choose/Array.chooseList.pick/Seq.pick/Array.pickList.tryPick/Seq.tryPick/Array.tryPickList.unfold/Seq.unfold/Array.unfoldThese are arguably the most useful to implement, since they (potentially) allocate one
optionobject for each item. If further prioritization is needed, then I'd guesschooseandtryPickare the most commonly used.(For the sake of completeness: Additional functions in these modules that could be implemented too are all the
tryXfunctions that return an option, but in this issue, I choose to concentrate only on the above.)I might be able to submit a PR if I get some general guidance on what to add where (never contributed code to FSharp.Core before). For example, should I duplicate existing functions but use
ValueSome/ValueNone, or should old functions delegate to new functions in some way, etc. (I suppose the performance will be best with completely separate definitions.) But I'm more than happy to let other people take it, too.