Giter Site home page Giter Site logo

Comments (7)

TheAngryByrd avatar TheAngryByrd commented on May 17, 2024

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.

cmeeren avatar cmeeren commented on May 17, 2024

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.

TheAngryByrd avatar TheAngryByrd commented on May 17, 2024

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.

cmeeren avatar cmeeren commented on May 17, 2024

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.

TheAngryByrd avatar TheAngryByrd commented on May 17, 2024

Make a PR 😄

from fstoolkit.errorhandling.

tamizhvendan avatar tamizhvendan commented on May 17, 2024

@cmeeren The latest version 1.2.2 has your changes. Can you verify and close this issue?

from fstoolkit.errorhandling.

cmeeren avatar cmeeren commented on May 17, 2024

It's there, thanks! 👍

from fstoolkit.errorhandling.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.