day 5 

Derived from Bello Nock's Sky Walk by Chris Phutully

Yesterday we reviewed Semigroup and Monoid, implementing custom monoids along the way. We also looked at Foldable that can foldMap etc.

Apply.ap 

Starting with a few updates today. First, Apply.apply that we looked at in day 3 has been renamed to Apply.ap #308.

Serializable typeclass instance 

In a previous version, checking the monoid laws on a value class kept tripping on Serializable. That turned out not to be Cats’ fault. I went into Cats’ gitter chat and Erik (@d6/@non) kindly pointed out that the reason my typeclass instances are not serializable is because they are defined on the REPL. Once I moved First to src/ the laws passed fine.

Jason Zaugg (@retronym) also pointed that, to support serialization beyond precisely the same version of Cats on both sides of the wire, we need to do more things like:

  • Avoid anonymous classes (to avoid class name change)
  • Tack @SerialVersionUID(0L) on everything