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

Port align instance for IO and SyncIO from CE2 #1775

Merged
merged 2 commits into from
Mar 15, 2021

Conversation

alexandrustana
Copy link
Contributor

This PR aims to fix #1726

@alexandrustana alexandrustana marked this pull request as ready for review March 10, 2021 12:21
Copy link
Member

@djspiewak djspiewak left a comment

Choose a reason for hiding this comment

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

Some minor comments, but otherwise looks very good!

@@ -1227,6 +1230,22 @@ object IO extends IOCompanionPlatform with IOLowPriorityImplicits {
a.handleErrorWith(_ => b)
}

implicit val alignForIO: Align[IO] =
Copy link
Member

Choose a reason for hiding this comment

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

It's worth following the pattern we have elsewhere: define alignForIO to be a def which delegates to private[this] val _alignForIO. I realize it's a bit arcane, but this actually produces performance benefits because it avoids the memory barriers associated with val on object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll switch to this implementation then.
Thanks for the tip :)

implicit val alignForIO: Align[IO] =
new IOAlign

protected class IOAlign extends Align[IO] {
Copy link
Member

Choose a reason for hiding this comment

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

Why protected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While adding alignForIO I've used semigroupKForIO as a reference. Didn't really thought it through when choosing the access specifier.

Comment on lines 501 to 504
implicit val alignForIO: Align[SyncIO] =
new SyncIOAlign

protected class SyncIOAlign extends Align[SyncIO] {
Copy link
Member

Choose a reason for hiding this comment

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

Same comments as with IO

@djspiewak
Copy link
Member

🎉

@djspiewak djspiewak merged commit 2a00841 into typelevel:series/3.x Mar 15, 2021
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.

Missing Align[IO] in CE3
2 participants