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 piecemeal import guide #1756

Merged
merged 4 commits into from
Sep 12, 2017
Merged

Conversation

LukaJCB
Copy link
Member

@LukaJCB LukaJCB commented Jul 5, 2017

Still a WIP, but looking for some early feedback. Should resolve #1668

@kailuowang
Copy link
Contributor

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.
Copy link
Contributor

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-io
Copy link

codecov-io commented Jul 12, 2017

Codecov Report

Merging #1756 into master will increase coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
core/src/main/scala/cats/Show.scala 100% <0%> (ø) ⬆️
kernel/src/main/scala/cats/kernel/Order.scala 89.18% <0%> (+0.3%) ⬆️
core/src/main/scala/cats/syntax/monoid.scala 100% <0%> (+100%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 99b543b...10a5db5. Read the comment docs.

@kailuowang kailuowang modified the milestone: 1.0.0-RC1 Aug 8, 2017
@LukaJCB LukaJCB changed the title Add piecemeal import guide (WIP) Add piecemeal import guide Aug 25, 2017
@kailuowang kailuowang modified the milestone: 1.0.0-RC1 Aug 29, 2017
@ceedubs
Copy link
Contributor

ceedubs commented Sep 12, 2017

🎉 so happy to see this finally land. It's something that I started on multiple times but never completed. Thanks @LukaJCB!

@ceedubs ceedubs merged commit eff36ef into typelevel:master Sep 12, 2017
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._
Copy link
Collaborator

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
Copy link
Collaborator

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.

@LukaJCB LukaJCB deleted the piecemeal-import-guide branch September 13, 2017 12:13
@kailuowang kailuowang added this to the 1.0.0-RC1 milestone Oct 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Piecemeal import guide
6 participants