Question

I am currently playing with Scalaz non-blocking futures aka. Promises. I am struggling to make the following function tail-recursive:

@tailrec
private def repeat( res: Promise[I] ):Promise[I] =
  res map p flatMap { 
    (b:Boolean) =>
      if( b ) repeat( res flatMap f ) else res
  }

where p is a predicate with type I=>Boolean and f is a concurrent function with type I=>Promise[I].

The method compiles without the annotation.

Any hints ? Thanks

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top