Hey there. There's an updated html5 book version, if you want.
Darren Hester for openphoto.net
Yesterday we looked at Reader monad as a way of abstracting configuration, and introduced monad transformers.
Today, let's look at lenses. It's a hot topic many people are talking, and looks like it has clear use case.
Go turtle go
Seth Tisue (@SethTisue) gave a talk on shapeless lenses at Scalathon this year. I missed the talk, but I am going to borrow his example.
scala> case class Point(x: Double, y: Double)
defined class Point
scala> case class Color(r: Byte, g: Byte, b: Byte)
defined class Color
scala> case class Turtle(
position: Point,
heading: Double,
color: Color)
scala> Turtle(Point(2.0, 3.0), 0.0,
Color(255.toByte, 255.toByte, 255.toByte))
res0: Turtle = Turtle(Point(2.0,3.0),0.0,Color(-1,-1,-1))