Make Result.defaultWith accept error, or remove it
cmeeren opened this issue · 2 comments
In F# 7, there is a built-in Result.defaultWith
where the thunk accepts the error instead of unit
(as in FsToolkit.ErrorHandling). This is a more useful signature.
When I open FsToolkit.ErrorHandling
, I get the less useful one that only accepts unit
(unless I open FSharp.Core
below, which I'd rather not since I prefer avoiding situations where the order of opens are critical.)
A simple workaround (though a breaking change) is to update Result.defaultWith
in FsToolkit.ErrorHandling to be identical to the one now implemented in FSharp.Core. Alternatively, it could be removed altogether.
This may be relevant for other Result
module functions, too.
Reference: Result module parity with Option
When I open FsToolkit.ErrorHandling, I get the less useful one that only accepts unit (unless I open FSharp.Core below, which I'd rather not since I prefer avoiding situations where the order of opens are critical.)
Agreed, I even agreed with the suggested change to FSharp.Core and forgot the make the change in this repo.
A simple workaround (though a breaking change) is to update Result.defaultWith in FsToolkit.ErrorHandling to be identical to the one now implemented in FSharp.Core. Alternatively, it could be removed altogether.
I think I'd still prefer a version here for two reasons.
- This repo is still available for F# 4.x
InlineIfLambda
This may be relevant for other Result module functions, too.
Yeah I'm sure this affects AsyncResult, TaskResult, and JobResult as well.
This may be relevant for other
Result
module functions, too.Yeah I'm sure this affects AsyncResult, TaskResult, and JobResult as well.
For clarification, I was referring to other Result
module functions that may have been added to FSharp.Core.