A Cats and Scalaz compatibility library.
Tired of writing separate code for Cats and Scalaz? All that preprocessor noise and those extra packages are too much work! Just pick between Scalaz and Cats. If your clients don't like your choice, they can use one import from this library to become happy.
We can all live together!
cats version | scalaz version | harmony version | dependency |
---|---|---|---|
0.8.1 | 7.2.* | 1.1 | "me.jeffshaw.harmony" %% "harmony_cats0-8-1_scalaz7-2" % "1.1" |
0.9.0 | 7.2.* | 1.1 | "me.jeffshaw.harmony" %% "harmony_cats0-9-0_scalaz7-2" % "1.1" |
1.0.0-MF | 7.2.* | 2.0 | "me.jeffshaw.harmony" %% "harmony_cats1-0-0-mf_scalaz7-2" % "2.0" |
cats version | scalaz version | harmony version | dependency |
---|---|---|---|
0.0.2 | 7.2.* | 2.0 | "me.jeffshaw.harmony" %% "harmony_cats-mtl-core0-0-2_scalaz7-2" % "2.0" |
The naming scheme will change if Cats or Scalaz change their binary compatibility guarantees. Cats has no such guarantee.
Harmony releases sharing an artifact name and major version should be binary compatible.
domain | codomain | type class | data types | both |
---|---|---|---|---|
Cats | Scalaz | import harmony.toscalaz.TypeClasses._ |
import harmony.toscalaz.Data._ |
import harmony.ToScalaz._ |
Scalaz | Cats | import harmony.tocats.TypeClasses._ |
import harmony.tocats.Data._ |
import harmony.ToCats._ |
Or, if you just want everyone to get along,
import harmony.Everyone._
Want a cats.Functor
for scalaz.IList
?
import harmony.tocats.typeclass.FunctorConverter._
cats.Functor[scalaz.IList]
Want to use a scalaz.Writer
in a cats.data.Writer
?
import cats.instances.int._
import harmony.tocats.data.WriterTConverter._
val tell3 = scalaz.WriterT.tell(3)
val w: cats.data.WriterT[cats.Id, Int, Unit] =
for {
_ <- cats.data.Writer.tell(2)
_ <- tell3
} yield ()
w.run // yields (5, ())
Please see the Google doc.
Please fork this repo, add the relevant conversions to the relevant files, and do a pull request.
Or you can open an issue describing the conversions you need and someone might do it for you.
Harmony could use many more tests. As the library gains popularity I will add more.
- minimize use of
val
for overrides. - Conversions that require a second instance require the instance be in the target library, not the source. For example, the converter to
cats.arrow.Choice
requires acats.functor.Profunctor
, not ascalaz.Profunctor
. - Cats moved some type classes to a separate package, cats-mtl-core. The converters for those type classes are in a new Harmony library.
- Initialization fixes
- Initial release