-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break circularity in TypeBounds with LazyRef wraps
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
enum Free[+F[_], A]: | ||
case Return(a: A) | ||
case Suspend(s: F[A]) | ||
case FlatMap[F[_], A, B]( | ||
s: Free[F, A], | ||
f: A => Free[F, B]) extends Free[F, B] | ||
|
||
def flatMap[F2[x] >: F[x], B](f: A => Free[F2,B]): Free[F2,B] = | ||
FlatMap(this, f) | ||
|
||
@annotation.tailrec | ||
final def step: Free[F, A] = this match | ||
case FlatMap(FlatMap(fx, f), g) => fx.flatMap(x => f(x).flatMap(y => g(y))).step | ||
case FlatMap(Return(x), f) => f(x).step | ||
case _ => this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
enum Foo[+H[_]]: | ||
case Bar[F[_]](f: Foo[F]) extends Foo[F] | ||
|
||
def test: Foo[H] = this match | ||
case Bar(Bar(f)) => Bar(f) | ||
case _ => this |