Lets say I develop a new public data structure, lets call it FancyList. It has no external dependencies and everybody loves it.
This FancyList turns out to be a Functor, Monad, MonoidK, and Traverse.
What is the best way to provide cats instances for these type classes to my users? The way I see it I can put them:
On the same library
- Con: Users that don't care about
catsnow depend on this library. Source code is also more confusing for them. - Pro: If I put the instances within the companion object of
FancyList, implicit resolution will automatically find them, without the need for the user to import implicits explicitly (the same way no need toimport cats.implicits._for instances onNonEmptyList)
On a new library
- Pro: No external dependencies. Big plus on simplicity.
- Con: Users that do care about cats would 1) Have to import an extra dependency, and 2) Import the implicit evidences explicitly ( the same way you have to
import cats.implicits._for instances on structures on the standard library).
Also, what if next month users ask support for scalaz? Which of the approaches would be more appropriate?
In general, my questions are:
- Is my pro/cons list accurate? Did I miss something?
- What are the main arguments that I should consider?
- What have other libraries in similar positions done? Any example you could give?