You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// scalacOptions += "-Ykind-projector:underscores"sealedabstractclassFree[+S[_, _], +E, +A] {
@inline finaldefflatMap[S1[e, a] >:S[e, a], B, E1>:E](fun: A=>Free[S1, E1, B]):Free[S1, E1, B] =Free.FlatMapped[S1, E, E1, A, B](this, fun)
@inline finaldefmap[B](fun: A=>B):Free[S, E, B] = flatMap(a =>Free.pure[S, B](fun(a)))
@inline finaldefas[B](as: =>B):Free[S, E, B] = map(_ => as)
@inline finaldef*>[S1[e, a] >:S[e, a], B, E1>:E](sc: Free[S1, E1, B]):Free[S1, E1, B] = flatMap(_ => sc)
@inline finaldef<*[S1[e, a] >:S[e, a], B, E1>:E](sc: Free[S1, E1, B]):Free[S1, E1, A] = flatMap(r => sc.as(r))
@inline finaldefvoid:Free[S, E, Unit] = map(_ => ())
// FIXME: Scala 3.1.4 bug: false unexhaustive match warning/// @nowarn("msg=pattern case: Free.FlatMapped")@inline finaldeffoldMap[S1[e, a] >:S[e, a], G[+_, +_]](transform: S1~>>G)(implicitG:Monad2[G]):G[E, A] = {
thismatch {
caseFree.Pure(a) =>G.pure(a)
caseFree.Suspend(a) => transform.apply(a)
caseFree.FlatMapped(sub, cont) =>
sub match {
caseFree.FlatMapped(sub2, cont2) => sub2.flatMap(a => cont2(a).flatMap(cont)).foldMap(transform)
case another =>G.flatMap(another.foldMap(transform))(cont(_).foldMap(transform))
}
}
}
}
trait~>>[-F[_, _], +G[_, _]] {
defapply[E, A](f: F[E, A]):G[E, A]
}
objectFree {
@inline defpure[S[_, _], A](a: A):Free[S, Nothing, A] =Pure(a)
@inline deflift[S[_, _], E, A](s: S[E, A]):Free[S, E, A] =Suspend(s)
finalcaseclassPure[S[_, _], A](a: A) extendsFree[S, Nothing, A] {
overridedeftoString:String=s"Pure:[$a]"
}
finalcaseclassSuspend[S[_, _], E, A](a: S[E, A]) extendsFree[S, E, A] {
overridedeftoString:String=s"Suspend:[$a]"
}
finalcaseclassFlatMapped[S[_, _], E, E1>:E, A, B](sub: Free[S, E, A], cont: A=>Free[S, E1, B]) extendsFree[S, E1, B] {
overridedeftoString:String=s"FlatMapped:[sub=$sub]"
}
}
typeMonad2[F[+_, +_]] =Monad3[λ[(`-R`, `+E`, `+A`) =>F[E, A]]]
traitMonad3[F[-_, +_, +_]] {
defflatMap[R, E, A, B](r: F[R, E, A])(f: A=>F[R, E, B]):F[R, E, B]
defflatten[R, E, A](r: F[R, E, F[R, E, A]]):F[R, E, A] = flatMap(r)(identity)
defpure[A](a: A):F[Any, Nothing, A]
}
Output
Recursion limit exceeded.
Maybe there is an illegal cyclic reference?If that's not the case, you could also try to increase the stacksize using the -XssJVM option.
For the unprocessed stack trace, compile with-Yno-decode-stacktraces.
A recurring operation is (inner to outer):
traversing for avoiding local references E$2
traversing for avoiding local references E1$1
traversing for avoiding local references E$2
traversing for avoiding local references E1$1
traversing for avoiding local references E$2
traversing for avoiding local references E1$1
traversing for avoiding local references E$2
traversing for avoiding local references E1$1
traversing for avoiding local references E$2
traversing for avoiding local references E1$1
...
traversing for avoiding local references E1$1
traversing for avoiding local references E$2
traversing for avoiding local references E1$1
traversing for avoiding local references E$2
traversing for avoiding local references E1$1
traversing for avoiding local references E$2
traversing for avoiding local references E1$1
traversing for avoiding local references E$2
traversing for avoiding local references E1$1
traversing for avoiding local references G[E1$1, B$1]
Expectation
Expected to compile, as on 3.2.2.
Workaround not found yet.
The text was updated successfully, but these errors were encountered:
Compiler version
3.3.0-RC1, 3.3.0-RC2, 3.3.1-RC1-bin-20230126-f545d10-NIGHTLY
Did not happen on 3.2.2
Minimized code
3.3.0-RC2: https://scastie.scala-lang.org/xmkJPcdSTRKnYucH905AoQ (Same code works on 3.2.2)
Output
Expectation
Expected to compile, as on 3.2.2.
Workaround not found yet.
The text was updated successfully, but these errors were encountered: