I often find myself wanting (and then usually writing) Scalaz type class instances for classes in other Scala or Java libraries. To give just a few examples:
A monoid instance for Shapeless's HList
gives you monoid instances for case classes with appropriately typed members almost for free.
An applicative functor instance for Lift's Box
allows you for example to sequence a list of boxes:
scala> val boxen: List[Box[Int]] = Full(1) :: Full(2) :: Full(3) :: Nil
boxen: List[net.liftweb.common.Box[Int]] = List(Full(1), Full(2), Full(3))
scala> boxen.sequence
res0: net.liftweb.common.Box[List[Int]] = Full(List(1, 2, 3))
A monad instance for Dispatch 0.9's Promise
(and Promise[Either[Throwable, _]]
, etc.) is hugely useful for all kinds of things.
An applicative functor instance for the standard library's Parser
makes applicative parsing more concise and elegant. (I just noticed that Scalaz 7 now provides a monad instance for Parser
.)
And so on...
These instances are almost always very general-purpose, and I'm sure lots of us have written lots of these lots of times. What I'm fishing for with this question is some kind of aggregator or clearinghouse for Scalaz type class instances. I'm not sure such a thing exists—I certainly haven't been able to find anything like it—but even just a collection of links to blog posts, GitHub repositories, or other resources would be useful to me.
I'd prefer Scalaz 7 instances, but I'll take anything I can get.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With