@Test public void testMap() { Cofree<Id_, Integer> cofree = Cofree.unfold(IdInstances.functor(), 0, a -> Id.of(a + 1)).map(x -> x * 2); Id<Tuple4<Cofree<Id_, Integer>, Cofree<Id_, Integer>, Cofree<Id_, Integer>, Cofree<Id_, Integer>>> tuple4Id = For.with(IdInstances.monad()) .then(cofree.tailForced()) .flatMap(Cofree::tailForced) .flatMap(Cofree::tailForced) .flatMap(Cofree::tailForced) .tuple().fix(toId()); assertEquals(Tuple.of(2, 4, 6, 8), tuple4Id.get().map(Cofree::extract, Cofree::extract, Cofree::extract, Cofree::extract)); }
public <B> Cofree<F, B> map(Function1<? super A, ? extends B> mapper) { return transform(mapper, c -> c.map(mapper)); }
Cofree implements CofreeOf<F, A> { public <B> Cofree<F, B> map(Function1<? super A, ? extends B> mapper) { return transform(mapper, c -> c.map(mapper)); } }
Cofree implements CofreeOf<F, A> { public <B> Cofree<F, B> map(Function1<? super A, ? extends B> mapper) { return transform(mapper, c -> c.map(mapper)); } private  Cofree(Functor<F> functor, A head, Eval<Kind<F, Cofree<F, A>>> tail); }
Cofree implements CofreeOf<F, A> { public <B> Cofree<F, B> map(Function1<? super A, ? extends B> mapper) { return transform(mapper, c -> c.map(mapper)); } 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 <B> Cofree<F, B> map(Function1<? super A, ? extends B> mapper) { return transform(mapper, c -> c.map(mapper)); } 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);  }