Skip to content
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

Remove subsumption from Applicatives #569

Merged
merged 12 commits into from
Nov 26, 2023
Merged

Remove subsumption from Applicatives #569

merged 12 commits into from
Nov 26, 2023

Conversation

gusty
Copy link
Member

@gusty gusty commented Nov 22, 2023

Same as #207 but rebased.

I gave it another try and looks like I found a way not to break anything, so no need to wait for v2.

This will allow Vector and Matrix to implement IEnumerable.
Another reason to implement this is removing dependencies between NonEmptySeq<'T> (now that F#8 allows static member on interfaces) and FSharpPlus.Control by creating its own static members #552

Also to the original issues:

Right now there are 2 issues ..

  • Types implementing IEnumerable<_> would default to the seq<_> instance. This might be arguably desired.
  • Types implementing IEnumerable<_> would default to the seq<_> instance, even if they implement their own applicative > instance. This is not acceptable.

.. I will amend the former like this:

  • Types implementing IEnumerable<_> would default to the seq<_> instance. This might be arguably desired, but it will result in unexpected behavior: different IEnumerables can have different applicative instances, this is becoming more evident in Non sequential Applicatives #559 for example a ZipList can be an IEnumerable but its applicative instance won't have the same result as if you cast it to seq and then use the applicative for sequences, therefore it's better to require either an explicit applicative implementation, or an explicit cast to seq. The other issue is the resulting type will be a seq<_> instead of the original type, which would break many things.

TODO

  • Add tests for the new functionality
  • Rebase on Adjust Value Task compilation flags #570 just to be sure nothing breaks
  • Reconsider final shape of the overloads (tuple, ref, struct tuple)
  • Reconsider the dummy type KeyValuePair2, move it to internals, use instead a DmStruct2<,>, ... -> DmStruct2 didn't work.

@gusty gusty force-pushed the gus/strict-applicatives branch 3 times, most recently from 1f29f2d to 8412408 Compare November 22, 2023 09:36
@gusty gusty force-pushed the gus/strict-applicatives branch from f69959b to ac46e9b Compare November 25, 2023 18:17
@gusty gusty force-pushed the gus/strict-applicatives branch from 70a50f4 to 029ed98 Compare November 25, 2023 18:41
@gusty gusty force-pushed the gus/strict-applicatives branch from e5a9c69 to 4f8ab5c Compare November 25, 2023 19:37
@gusty gusty marked this pull request as ready for review November 25, 2023 20:06
@gusty gusty force-pushed the gus/strict-applicatives branch from 7a36bbb to 9474025 Compare November 25, 2023 20:30
Copy link
Member

@cannorin cannorin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@gusty gusty changed the title Use strict types for applicatives (rebased) Remove subsumption from Applicatives Nov 26, 2023
@gusty gusty merged commit 52fa7b7 into master Nov 26, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants