-
Notifications
You must be signed in to change notification settings - Fork 519
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
Conversation
There was a problem hiding this 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] = |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why protected
?
There was a problem hiding this comment.
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.
implicit val alignForIO: Align[SyncIO] = | ||
new SyncIOAlign | ||
|
||
protected class SyncIOAlign extends Align[SyncIO] { |
There was a problem hiding this comment.
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
🎉 |
This PR aims to fix #1726