-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non sequential Applicatives #559
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gusty
force-pushed
the
master
branch
4 times, most recently
from
October 15, 2023 05:01
9b34ece
to
b2f3c8c
Compare
4 tasks
gusty
force-pushed
the
master
branch
2 times, most recently
from
December 18, 2023 08:18
484cff5
to
142c806
Compare
gusty
force-pushed
the
gus/parallel
branch
2 times, most recently
from
January 13, 2024 07:00
fdee9ed
to
be059d7
Compare
gusty
force-pushed
the
gus/parallel
branch
3 times, most recently
from
January 13, 2024 07:58
b76ebfa
to
be059d7
Compare
gusty
force-pushed
the
gus/parallel
branch
6 times, most recently
from
January 24, 2024 14:29
4af4297
to
c5de07d
Compare
gusty
force-pushed
the
gus/parallel
branch
2 times, most recently
from
January 25, 2024 06:01
416f433
to
c284312
Compare
wallymathieu
approved these changes
Jan 28, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a key feature, we introduce a "parallel" instance of Applicatives which are normally not monads and therefore don't have sequential behavior.
The goal is to remove a bit friction when using the "interesting" applicative instances without breaking some basic rules which provides useful properties, but adding a different set of operation instead of the classical solution of new-type which involves wrapping and unwrapping all the time and pollutes a lot a simple piece of code.
We call them ZipApplicatives as existing F# core zip-like operations like
zip
tend to match them.It's hard to define additional rules for them, but I would say in general we can expect the full
zip
-unzip
roundtrip.Nevertheless the rule that they don't obey is sequential guarantee, as opposed to the ones derived by Monads.
For Validation it was stated the above roundtrip doesn't hold (see #280), but actually if the monoid type is a set-like it does.
In general, list like will behave point-wise and computations will start in sequence but can finish in any order. The latter is not exactly the same as full parallel which would require using the threadpool, see dotnet/fsharp#10301 (comment) for more context on this distinction.
This design takes into consideration the principle of less surprising, namely:
<*>
equivalent to</ap/>
which would give bad surprises in refactorings/optimizations.Fixes #36
Partially inspired by Parallel