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

Add primary associated type for MarkupVisitor #135

Merged
merged 3 commits into from
May 20, 2024

Conversation

Kyle-Ye
Copy link
Contributor

@Kyle-Ye Kyle-Ye commented Jul 6, 2023

Bug/issue #, if applicable:

Summary

Add primary associated type for MarkupVisitor

Update: Bump the minimal supported Swift version to Swift 5.7

Alternatives

The current implementation of PAT support for MarkupVisitor has a lot of duplicated code since PAT was introduced by Swift 5.7.

We could drop such duplication if we can update this Package's min supported Swift version to Swift 5.7.

See #78

Testing

See MarkupVisitorTests.swift

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary

@QuietMisdreavus
Copy link
Contributor

I think there's a broader discussion to be had about upgrading the minimum Swift version for Swift-DocC and its dependencies. This could probably be a Documentation Workgroup topic, IMO.

@Kyle-Ye Kyle-Ye mentioned this pull request Jul 6, 2023
@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Jul 6, 2023

I think there's a broader discussion to be had about upgrading the minimum Swift version for Swift-DocC and its dependencies. This could probably be a Documentation Workgroup topic, IMO.

If we can upgrade min-supported version to Swift 5.7. I think this PR is fairly easy to be merged.

If we decide to maintain a Swift version lower than Swift 5.7, it looks like we need to maintain such huge duplication of code to get PAT support.

Do you think this PR is generally fine even if we still need to target a swift version lower than 5.7?

@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Jul 17, 2023

Follow the swift repo's style, I just added 2 labels for this repo so that we can better tag this for the future PR.

I'll remove the "pending discussion" label to "approved" when the meeting notes is posted on the forum.

image

@Kyle-Ye Kyle-Ye added New Feature SDWG meeting pending discussion Swift Documentation Workgroup Meeting Pending Discussion labels Jul 17, 2023
@Kyle-Ye Kyle-Ye added SDWG meeting approved Swift Documentation Workgroup meeting approved and removed SDWG meeting pending discussion Swift Documentation Workgroup Meeting Pending Discussion labels Jul 25, 2023
@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Jul 25, 2023

@swift-ci please test

@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Jul 25, 2023

I think there's a broader discussion to be had about upgrading the minimum Swift version for Swift-DocC and its dependencies. This could probably be a Documentation Workgroup topic, IMO.

The Swift 5.7 bump was discussed and got approved at last week's meeting.

I think this PR is now ready for review. @QuietMisdreavus

@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Sep 21, 2023

For PAT support, it unlocks more usage for the downstream user. Basically the same as Combine add PAT for Publisher protocol Publisher<Output, Failure>
Before the PR, we can only use some MarkupVisitor and can't do anything for the result of visit method since it is unbound.

var vistor: some MarkupVisitor = EmptyWalker()
let result = vistor.visit(Text(""))
// Can't do anything on result

After the PR, we can unlock something very interesting for the downstream user. See the latest test case. 84a2048
(The original test case use MarkupWalker whose Result type is Void and may not fully express the idea. I've update the test case to show the PAT's usage)

You may also have a check here https://www.swiftbysundell.com/articles/opaque-return-types-primary-associated-types/ which has a great explanation for PAT.

@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Sep 21, 2023

@swift-ci please test

@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Apr 8, 2024

@swift-ci please test

@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented May 20, 2024

@swift-ci please test

@Kyle-Ye Kyle-Ye merged commit 365bf2d into swiftlang:main May 20, 2024
2 checks passed
@Kyle-Ye Kyle-Ye deleted the feature/kyle/pat branch May 20, 2024 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Feature SDWG meeting approved Swift Documentation Workgroup meeting approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants