Comments (7)
Usually when I end up with that situation I haven't done something right. The functions all need to align to the expected output type which is Async<Result<Webhook, Error>>
.
So for instance I would create some helpers do:
//looks like were missing some of these helper functions like AsyncResult.ofAsync or AsyncResult.ofResult
module AsyncResult=
let ofAsync (a : Async<_>) = a |> Async.map Result.Ok
let ofResult (r : Result<_,_>) = r |> Async.singleton
let createWebhook = Workflows.createWebhook |> AsyncResult.ofAsync
let parseRequiredAttr x y = parseRequiredAttr x y |> AsyncResult.ofResult
let parseOptOptAttr x y = parseOptOptAttr x y |> AsyncResult.ofResult
Then in the implementation use the AsyncResult operators to do:
let! webhook =
createWebhook
<!> parseRequiredAttr a.callbackUrl WebhookCallbackUrl.TryCreate
<*> parseOptOptAttr a.authorizationHeader WebhookAuthorizationHeader.TryCreate
The reason I'm loosely against this is because I've seen people just trying to make types fit without actually understanding what is going on. That said I could be totally wrong about this.
from fstoolkit.errorhandling.
The operators I'm using are the Validation
operators, and they are only available for Result
.
Besides, is there a significant conceptual difference between using wrappers to make all the types match up up front (or as you go along and call them), versus transforming once at the end? The latter seems to be less work/verbose.
from fstoolkit.errorhandling.
The operators I'm using are the Validation operators, and they are only available for Result.
Looks like we should also add those for Async/Task/JobResult variants too :)
The latter seems to be less work/verbose.
Yeah, that is definitely a downside to the alternative I have given.
from fstoolkit.errorhandling.
Looks like we should also add those for Async/Task/JobResult variants too :)
Would be great! In my specific case, I'd still want Result.sequenceAsync
though, both due to being less boilerplate, and because it's confusing to have to switch back and forth between different operators.
from fstoolkit.errorhandling.
Make a PR
from fstoolkit.errorhandling.
@cmeeren The latest version 1.2.2
has your changes. Can you verify and close this issue?
from fstoolkit.errorhandling.
It's there, thanks!
from fstoolkit.errorhandling.
Related Issues (20)
- F# 6 task CE support (instead of Ply) HOT 1
- Task to AsyncResult transition wraps `Exception` into the `AggregateException` HOT 8
- Seq.sequenceResultM returns a list instead of a seq HOT 1
- TaskResult.ofTask? HOT 2
- Use ListCollector on List operations to improve perf HOT 4
- List.traverseValidationA' should be private? HOT 1
- Add explicit type parameters to ignore functions HOT 5
- Move TaskResult (and friends) to core FsToolkit.ErrorHandling package HOT 9
- TaskResultCE breaks with a bind in branching such as if HOT 2
- List.traverseResultA and friends have x @ y on the error branch, this could potentially blow up HOT 5
- Add Option.maybe
- Task wrapped result + option helpers HOT 1
- Worried about the Diamond dependency problem HOT 6
- Documentation for Validation operators mentions Bind (>>=), but the library doesn't implement it HOT 1
- Should List.sequenceValidationA preserve order? HOT 2
- FSharp.Core version warning (net7.0) HOT 14
- Make Result.defaultWith accept error, or remove it HOT 2
- Overload issues with TaskResult on generic functions HOT 2
- Add Option.ofPair HOT 5
- Add asyncValidation CE, or make asyncResult (and result?) CEs work with 'and!' HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fstoolkit.errorhandling.