We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
We provided a monad implementation based on map, flatMap methods in an instance, and the apply method in its companion object.
map
flatMap
apply
We support Seq monad, Set monad and a lot of other collection monads in this way.
Seq
Set
Simply import the implicit method in ComprehensionImplicits, and it will provide Monad for all types that supports for comprehension.
ComprehensionImplicits
Monad
for
import com.thoughtworks.each.ComprehensionImplicits._ import com.thoughtworks.each.Monadic._ def plusOne(intSeq: Seq[Int]) = monadic[Seq] { intSeq.each + 1 } assertEquals(Seq.empty, plusOne(Seq.empty)) assertEquals(Seq(16), plusOne(Seq(15))) assertEquals(Seq(16, -1, 10), plusOne(Seq(15, -2, 9)))