public
Created

A Bit More Generic Writer MOnad

  • Download Gist
gistfile1.scala
Scala
1 2 3 4 5 6 7 8
case class Writer[A](value: A, diary: String) = {
def flatMap[B](f: A => Writer[B]) = {
f(value) match {
case Writer(result, d) => Writer(result, diary + d)
}
}
def map[B](f: A => B]) = Writer(f(value), diary)
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.