|
Scala example source code file (LazyEitherTest.scala)
The LazyEitherTest.scala Scala example source codepackage scalaz import scalaz.scalacheck.ScalazProperties._ import scalaz.scalacheck.ScalazArbitrary._ import std.AllInstances._ object LazyEitherTest extends SpecLite { implicit def LazyEitherEqual[A: Equal, B: Equal]: Equal[LazyEither[A, B]] = new Equal[LazyEither[A, B]] { def equal(a: LazyEither[A, B], b: LazyEither[A, B]) = Equal[Either[A, B]].equal(a.toEither,b.toEither) } checkAll(equal.laws[LazyEither[Int,Int]]) checkAll(monad.laws[LazyEither[Int, ?]]) checkAll(monadError.laws[LazyEither[Int, ?], Int]) checkAll(bindRec.laws[LazyEither[Int, ?]]) checkAll(traverse.laws[LazyEither[Int, ?]]) checkAll(associative.laws[LazyEither]) checkAll(bitraverse.laws[LazyEither]) "tail recursive tailrecM" in { val times = 10000 val result = BindRec[LazyEither[Int, ?]].tailrecM[Int, Int] { i => LazyEither.lazyRight(if (i < 10000) \/.left(i + 1) else \/.right(i)) }(0) result.getOrElse(0) must_=== times } } Other Scala examples (source code examples)Here is a short list of links related to this Scala LazyEitherTest.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.