I am trying to do the following in as little code as possible and as functionally as possible:
def restrict(floor : Option[Double], cap : Option[Double], amt : D
This isn't really much easier in Scalaz than in regular Scala:
def restrict(floor: Option[Double], cap: Option[Double], amt: Double) =
floor.map(amt max).orElse(Some(amt)).map(x => cap.map(x min).getOrElse(x)).get
(Add _
after max
and min
if it makes you feel better to see where the parameter goes.)
Scalaz is a little easier to read, though, once you understand what the operators do.