-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 piecemeal import guide #1756
Conversation
Thanks! looking good to me so far. |
``` | ||
The first import pulls the `Semigroup` instance for String into the scope, while the second import adds the `|+|` syntax. | ||
|
||
You can also import all syntax or all instances by importing `cats.instances.all._` or `cats.syntax.all._` respectively. |
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.
Isn't this mixed up? I.e., it should be something like "(syntax or instances) ... (cats.syntax.all._
or cats.instances.all._
) respectively". (Although english is not my first language.)
Codecov Report
@@ Coverage Diff @@
## master #1756 +/- ##
==========================================
+ Coverage 94.17% 94.22% +0.04%
==========================================
Files 256 256
Lines 4207 4208 +1
Branches 93 93
==========================================
+ Hits 3962 3965 +3
+ Misses 245 243 -2
Continue to review full report at Codecov.
|
🎉 so happy to see this finally land. It's something that I started on multiple times but never completed. Thanks @LukaJCB! |
For example, if you'd like to import the `Monoid` instance for `String` and the corresponding syntax: | ||
```tut:book | ||
import cats.instances.string._ | ||
import cats.syntax.monoid._ |
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.
I was surprised this actually worked and we didn't need import cats.syntax.semigroup._
, but it seems that MonoidSyntax
extends SemigroupSyntax
.
It seems that all the kernel syntax extends their "super syntax traits", which is another inconsistency between cats-kernel and cats-core (even though this syntax is in cats-core).
|
||
//now we also need access to isEmpty from Monoid | ||
import cats.syntax.monoid._ | ||
(x |+| 1).isEmpty //error: value |+| is not a member of Int |
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.
If MonoidSyntax
didn't extend SemigroupSyntax
, we wouldn't have this issue.
You would only have this issue when you use cats.implicits._
or cats.xxx.all._
in combination with an a la carte import.
Still a WIP, but looking for some early feedback. Should resolve #1668