Giter VIP home page Giter VIP logo

Comments (8)

wallymathieu avatar wallymathieu commented on May 16, 2024

I've experimented with making tuples instead of only choosing one over the other, however that gives some other weirdness.

from fsharpplus.

gusty avatar gusty commented on May 16, 2024

With tuples, I guess it will not "type check" the expected signatures.

I think we can use a new wrapper type, like Validation to achieve the other behavior. I mean validations are the opposite, between a Good and a Bad they prefer the Bad and they accumulate the bad ones. So if we go with the Plus I proposed above, validation will be exactly its dual.

from fsharpplus.

gusty avatar gusty commented on May 16, 2024

I was thinking, if we keep the notion of the Alternative as executing alternatives we can also make Async an instance of Append. It will run the first async, then do an Async.Catch and then if it fails will run the second.
This could be useful now with the coming redesign of generic Computation Expressions, where the user will have a separate builder for MonadPlus (or Alternative) computations.

Unless there is a more interesting Append for async?

from fsharpplus.

gusty avatar gusty commented on May 16, 2024

OK, I have two proposals:

  1. https://github.com/gusty/FSharpPlus/tree/alt-for-result
  2. https://github.com/gusty/FSharpPlus/tree/consistent-alt-for-result

They differ in case no alternative is choosen (all failures) 1 returns the last failure whereas 2 requires that failures form a Semigroup and so it returns all of them.

Regarding the failures for plus 1 returns the first one and 2 all of them (requires semigroup).

from fsharpplus.

wallymathieu avatar wallymathieu commented on May 16, 2024

I like the 2) approach.

from fsharpplus.

gusty avatar gusty commented on May 16, 2024

I also sympathize with approach 2.
In contrast, here's an explanation of how IO works with what seems to be approach 1: https://stackoverflow.com/questions/48450826/what-is-the-purpose-of-instance-alternative-io

cc: @drvink

from fsharpplus.

drvink avatar drvink commented on May 16, 2024

I would also go with the second approach. I'm familiar with the instance for Alternative IO described in the link, though it's never really sat well with me!

from fsharpplus.

gusty avatar gusty commented on May 16, 2024

Deciding over the second option, closing by ce2f8bb

from fsharpplus.

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.