Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions free/src/main/scala/cats/free/Free.scala
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,5 @@ sealed abstract class Free[S[_], A] extends Product with Serializable {

final def compile[T[_]](f: FunctionK[S,T]): Free[T, A] = mapSuspension(f)

override def toString(): String = "Free(...)"
}
2 changes: 2 additions & 0 deletions free/src/main/scala/cats/free/FreeApplicative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ sealed abstract class FreeApplicative[F[_], A] extends Product with Serializable
def apply[B](fa: F[B]): Free[F, B] = Free.liftF(fa)
}
}

override def toString(): String = "FreeApplicative(...)"
}

object FreeApplicative {
Expand Down
6 changes: 6 additions & 0 deletions free/src/test/scala/cats/free/FreeApplicativeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class FreeApplicativeTests extends CatsSuite {
checkAll("FreeApplicative[Option, ?]", ApplicativeTests[FreeApplicative[Option, ?]].applicative[Int, Int, Int])
checkAll("Monad[FreeApplicative[Option, ?]]", SerializableTests.serializable(Applicative[FreeApplicative[Option, ?]]))

test("toString is stack-safe") {
val r = FreeApplicative.pure[List, Int](333)
val rr = (1 to 1000000).foldLeft(r)((r, _) => r.map(_ + 1))
rr.toString.length should be > 0
}

test("FreeApplicative#fold") {
val n = 2
val o1 = Option(1)
Expand Down
6 changes: 6 additions & 0 deletions free/src/test/scala/cats/free/FreeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class FreeTests extends CatsSuite {
checkAll("Free[Option, ?]", MonadRecTests[Free[Option, ?]].monadRec[Int, Int, Int])
checkAll("MonadRec[Free[Option, ?]]", SerializableTests.serializable(MonadRec[Free[Option, ?]]))

test("toString is stack-safe") {
val r = Free.pure[List, Int](333)
val rr = (1 to 1000000).foldLeft(r)((r, _) => r.map(_ + 1))
rr.toString.length should be > 0
}

test("mapSuspension id"){
forAll { x: Free[List, Int] =>
x.mapSuspension(FunctionK.id[List]) should === (x)
Expand Down