cyclops.free.Yoneda Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cyclops-pure Show documentation
Show all versions of cyclops-pure Show documentation
Platform for Functional Reactive Programming with Java 8
package cyclops.free;
import com.oath.cyclops.hkt.Higher;
import com.oath.cyclops.hkt.DataWitness.yoneda;
import cyclops.typeclasses.functor.Functor;
import java.util.function.Function;
public interface Yoneda extends Higher, T> {
public static Yoneda of(Higher hkt, Functor functor){
return new Yoneda(){
@Override
public Higher apply(Function super T, ? extends R> inner) {
return functor.map(inner,hkt);
}
};
}
Higher apply(Function super T, ? extends R> fn);
default Higher run(){
return apply(a->a);
}
default Yoneda map(Function super T, ? extends R> outer, Functor functor){
return new Yoneda(){
@Override
public Higher apply(Function super R, ? extends R1> inner) {
return Yoneda.this.apply(i->inner.apply(outer.apply(i)));
}
};
}
}