complain about and the ones nobody uses.” - Bjarne Stroustrup * applicable to libraries as well * source: http://www.stroustrup.com/bs_faq.html#really-say-that
mostly engineers with non functional backgrounds who came up to speed on scalaz and FP concepts * our code is cleaner and more expressive from using it
with NaturalEqual { def equal(a1: A, a2: A) = a1 == a2 } Magic? Defined in trait Equals. Defined in Identity[A]. def ===(a: A)(implicit e: Equal[A]): Boolean = e equal (value, a) * string implicitly converted to Identity[String] * https://github.com/scalaz/scalaz/blob/master/core/src/main/scala/scalaz/Identity.scala
w | false val y = “foo”.some val z = ~y // y | “” Implicit zero with primitive types. How does this work? def unary_~(implicit z: Zero[A]): A = { value getOrElse z.zero } OptionW[A]
Option[NonEmptyList] => Option[List] val x: List[Int] = List(1,2,3) val y: Option[NonEmptyList[Int]] = x.toNel val z: Option[List[Int]] = y.map(_.list) * impossible to create a NonEmptyList that is empty
Validation[E, A] final case class Failure[E, A](e: E) extends Validation[E, A] Represents failure and success. * similar to Either with Left and Right, but with less obscure names
method for creating Validations. pure “lifts” a into a Function0 def throws: Validation[Throwable, T] = try { success(a()) } catch { case e => failure(e) } (Function0W) * https://github.com/scalaz/scalaz/blob/master/core/src/main/scala/scalaz/Function0W.scala
x: scalaz.effects.IO[Unit] = scalaz.effects.IO$$anon $2@13d5047e scala> x.unsafePerformIO hi IO (side-effects) only happen when you call unsafePerformIO
17+) • Learn You a Scalaz - https://github.com/jrwest/learn_you_a_scalaz • Scalaz For the Rest of Us - http://arosien.github.com/scalaz-base-talk-201208 • Scalaz on GitHub - https://github.com/scalaz/scalaz • Comprehending Monads - http://marakana.com/static/courseware/scala/ presentation/comprehending-monads.html