Comments (8)
I've experimented with making tuples instead of only choosing one over the other, however that gives some other weirdness.
from fsharpplus.
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.
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.
OK, I have two proposals:
- https://github.com/gusty/FSharpPlus/tree/alt-for-result
- 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.
I like the 2) approach.
from fsharpplus.
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.
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.
Deciding over the second option, closing by ce2f8bb
from fsharpplus.
Related Issues (20)
- Reader monad transform one env to another HOT 6
- Generic monad functions with SeqT HOT 5
- The link to Result does not work. HOT 2
- Groups should be NonEmptySeqs
- Juxt HOT 9
- GitHub Action to release docs
- Validation.ofResult doesn't require Semigroup
- `(>>=)` should be constrained with `Map` HOT 8
- New Validation type HOT 2
- Array.replace takes in seq for its two first values instead of arrays
- Adjust package info with icon and license elements
- Add more static member operators like >=> HOT 1
- `String.take 0 s` throws IndexOutOfRangeException HOT 2
- Traverse Lens Documentation Needs more Examples HOT 1
- Documentation table of contents is missing list of namespaces HOT 3
- Proposal: A set of modules for list and tree zippers HOT 1
- Upload packages built on main branch onto GitHub NuGet feed
- Int32.TryParse and F#+ tryParse give different results HOT 6
- Fable 4 support HOT 3
- Type inference issue with applicative2 HOT 1
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 fsharpplus.