Skip to content

Commit

Permalink
Merge pull request #2344 from ceedubs/defer-doctest
Browse files Browse the repository at this point in the history
Use sbt-doctest for Defer example
  • Loading branch information
ceedubs authored Jul 30, 2018
2 parents 2ff0425 + 950b3af commit 7573e7a
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions core/src/main/scala/cats/Defer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ package cats
* The law is that defer(fa) is equivalent to fa, but not evaluated immediately,
* so
* {{{
* import cats._
* import cats.implicits._
* scala> import cats._
* scala> import cats.implicits._
*
* var evaluated = false
* val dfa =
* Defer[Eval].defer {
* evaluated = true
* Eval.now(21)
* }
* scala> var evaluated = false
* scala> val dfa = Defer[Eval].defer {
* | evaluated = true
* | Eval.now(21)
* | }
*
* assert(!evaluated)
* Eq[Eval[Int]].eqv(dfa, Eval.now(21))
* scala> evaluated
* res0: Boolean = false
*
* scala> Eq[Eval[Int]].eqv(dfa, Eval.now(21))
* res1: Boolean = true
* }}}
*/
trait Defer[F[_]] extends Serializable {
Expand Down

0 comments on commit 7573e7a

Please sign in to comment.