@Test public void testRun(@Mock Operator1<Integer> plus1) { when(plus1.apply(anyInt())) .thenReturn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); Cofree<Option_, Integer> cofree = Cofree.unfold(OptionInstances.functor(), 0, a -> (a < 10) ? Option.some(plus1.apply(a)) : Option.<Integer>none()); verify(plus1, never()).apply(anyInt()); cofree = cofree.run(); verify(plus1, times(10)).apply(anyInt()); assertEquals("0,1,2,3,4,5,6,7,8,9,10", cofree.reduceToString(EvalInstances.applicative(), OptionInstances.traverse(), (a, b) -> a + "," + b).value()); }
public Cofree<F, A> run() { Eval<Kind<F, Cofree<F, A>>> transformTail = transformTail(Cofree::run); return of(functor, head, Eval.now(transformTail.value())); }
Cofree implements CofreeOf<F, A> { public Cofree<F, A> run() { Eval<Kind<F, Cofree<F, A>>> transformTail = transformTail(Cofree::run); return of(functor, head, Eval.now(transformTail.value())); } }
Cofree implements CofreeOf<F, A> { public Cofree<F, A> run() { Eval<Kind<F, Cofree<F, A>>> transformTail = transformTail(Cofree::run); return of(functor, head, Eval.now(transformTail.value())); } private  Cofree(Functor<F> functor, A head, Eval<Kind<F, Cofree<F, A>>> tail); }
Cofree implements CofreeOf<F, A> { public Cofree<F, A> run() { Eval<Kind<F, Cofree<F, A>>> transformTail = transformTail(Cofree::run); return of(functor, head, Eval.now(transformTail.value())); } private  Cofree(Functor<F> functor, A head, Eval<Kind<F, Cofree<F, A>>> tail); A extract(); Kind<F, Cofree<F, A>> tailForced(); Cofree<F, A> runTail(); Cofree<F, A> run(); Cofree<F, B> map(Function1<? super A, ? extends B> mapper); Cofree<F, B> coflatMap(Function1<? super Cofree<F, ? extends A>, ? extends B> mapper); Eval<B> fold(Applicative<Eval_> applicative, Traverse<F> traverse, Function2<A, Kind<F, B>, Eval<B>> mapper); Eval<B> reduce(Applicative<Eval_> applicative, Traverse<F> traverse,
                            Function1<A, B> initial, Operator2<B> combine); Eval<String> reduceToString(Applicative<Eval_> applicative, Traverse<F> traverse, Operator2<String> join); Cofree<F, B> transform(Function1<? super A, ? extends B> headMap, 
      Function1<? super Cofree<F, ? extends A>, ? extends Cofree<F, ? extends B>> tailMap); static Cofree<F, A> unfold(Functor<F> functor, A head, Function1<A, Kind<F, A>> unfold); static Cofree<F, A> of(Functor<F> functor, A head, Eval<Kind<F, Cofree<F, A>>> tail); }
Cofree implements CofreeOf<F, A> { public Cofree<F, A> run() { Eval<Kind<F, Cofree<F, A>>> transformTail = transformTail(Cofree::run); return of(functor, head, Eval.now(transformTail.value())); } private  Cofree(Functor<F> functor, A head, Eval<Kind<F, Cofree<F, A>>> tail); A extract(); Kind<F, Cofree<F, A>> tailForced(); Cofree<F, A> runTail(); Cofree<F, A> run(); Cofree<F, B> map(Function1<? super A, ? extends B> mapper); Cofree<F, B> coflatMap(Function1<? super Cofree<F, ? extends A>, ? extends B> mapper); Eval<B> fold(Applicative<Eval_> applicative, Traverse<F> traverse, Function2<A, Kind<F, B>, Eval<B>> mapper); Eval<B> reduce(Applicative<Eval_> applicative, Traverse<F> traverse,
                            Function1<A, B> initial, Operator2<B> combine); Eval<String> reduceToString(Applicative<Eval_> applicative, Traverse<F> traverse, Operator2<String> join); Cofree<F, B> transform(Function1<? super A, ? extends B> headMap, 
      Function1<? super Cofree<F, ? extends A>, ? extends Cofree<F, ? extends B>> tailMap); static Cofree<F, A> unfold(Functor<F> functor, A head, Function1<A, Kind<F, A>> unfold); static Cofree<F, A> of(Functor<F> functor, A head, Eval<Kind<F, Cofree<F, A>>> tail);  }