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

Guideline for adding functionality without breaking binary compatibility. #2142

Open
kailuowang opened this issue Jan 8, 2018 · 1 comment

Comments

@kailuowang
Copy link
Contributor

kailuowang commented Jan 8, 2018

To maintain binary compatibility we can't add new methods with default implementation to existing traits. However we can add new traits with those and have classes extending them.
For example, we want to add a new method to a Typeclass TC[F[_]]. we could either provide a syntax trait that provides that method like

trait BOps2 {
    abstract class BOps2Ex[F[_], A](fa: F[A])(implicit val F: TC[F]) {
       def newMethod ???
    }
   implicit def bops[F[_], A](fa: F[A])(implicit val F: TC[F]) = new BOps2Ex(fa) 
}  

If this new method cannot be provided as a syntax to the data types we can add an implicit class against the Typeclass itself.
In both case, we can't have any existing trait extend these new trait. We would need to have several objects in cats inherit this new trait explicitly including cats.implicits cats.syntax.all, etc.

We should decide on a strategy and document in guideline.

@kailuowang
Copy link
Contributor Author

#2148 provides a fine example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant