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

New resolution #63

Merged
merged 11 commits into from
Oct 24, 2017
Merged

New resolution #63

merged 11 commits into from
Oct 24, 2017

Conversation

kailuowang
Copy link
Contributor

@kailuowang kailuowang commented Oct 9, 2017

These changes will allow semi-automatic derivation for most of the type classes,
By semi-automatic derivation I mean you would still need to write an explicit derivation for Foo, e.g. implicit val foo = cats.derive.show[Foo], but whatever references Foo has, their Show instances will be automatically derived if not provided in the scope.
Here is an more detailed example that I added to the README

scala> case class Address(street: String, city: String, state: String)
scala> case class ContactInfo(phoneNumber: String, address: Address)
scala> case class People(name: String, contactInfo: ContactInfo)
scala> val mike = People("Mike", ContactInfo("202-295-3928", Address("1 Main ST", "Chicago", "IL")))
scala> import cats._,cats.implicits._

scala> //existing show instance for Address
scala> implicit val addressShow: Show[Address] = new Show[Address]{ 
          def show(a: Address) = s"${a.street}, ${a.city}, ${a.state}" 
       }  

scala> implicit val peopleShow = derive.show[People] //auto derive Show for People

scala> mike.show
res0: String = People(name = Mike, contactInfo = ContactInfo(phoneNumber = 202-295-3928, address = 1 Main ST, Chicago, IL))

The cost is on the kittens side - I had to duplicated code at several places due to slightly different type signature on things like IsCCons1 or Split, etc. Maybe we can improve that later.
I also removed several Lazy usages. Should fix #61

@@ -5,15 +5,35 @@ package cats
* Use cats.derive to explicitly derive instance instead
*/
package object derived {
@deprecated("use cats.derive.emptemptyy instead", "1.0.0-RC1")
Copy link
Member

Choose a reason for hiding this comment

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

I believe this should be cats.derive.empty?

@kailuowang kailuowang merged commit 64e2886 into typelevel:master Oct 24, 2017
@kailuowang kailuowang deleted the new-resolution branch October 24, 2017 17:20
@durban durban mentioned this pull request Dec 15, 2017
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.

Remove unnecessary uses of Lazy
2 participants