forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes scala#9287 Closes scala#12640 Closes scala#12896
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package x | ||
|
||
trait CpsMonad[F[_]]: | ||
def pure[A](x:A): F[A] | ||
def flatMap[A,B](fa:F[A])(f: A=>F[B]): F[B] | ||
|
||
abstract sealed class CpsStream[-F[_],+T] | ||
|
||
case class Cons[F[_],T](head:T, tailFun: ()=>F[CpsStream[F,T]]) extends CpsStream[F,T] | ||
|
||
case class Empty[F[_]]() extends CpsStream[F,Nothing] | ||
|
||
def unfold[S,F[_]:CpsMonad,T](s0:S)(f:S => F[Option[(S,T)]]):F[CpsStream[F,T]] = | ||
summon[CpsMonad[F]].flatMap(f(s0)){ | ||
case Some(s1,a) => Cons(a, () => unfold(s1,f)) // error (used to crash) | ||
case None => summon[CpsMonad[F]].pure(Empty[F]()) | ||
} |
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,7 @@ | ||
object Foo { | ||
Nil { | ||
class i0 { a: i2 => // error | ||
class i1 | ||
} | ||
} // error | ||
} |
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,12 @@ | ||
trait IO[E] { | ||
def map[B](f: Any => B): IO[E] = ??? | ||
def flatMap[C](f: Any => IO[C]): IO[E | C] = ??? | ||
} | ||
|
||
class Test { | ||
def test: Unit = { | ||
val a: IO[Nothing] = ??? | ||
|
||
val d = a.flatMap(y => a.flatMap(z => a.map(_ => z))) | ||
} | ||
} |