cyclops.arrow.Cokleisli 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
The newest version!
package cyclops.arrow;
import com.oath.cyclops.hkt.Higher;
import com.oath.cyclops.types.functor.Transformable;
import cyclops.function.Function1;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import cyclops.data.tuple.Tuple2;
import java.util.function.Function;
@AllArgsConstructor(access= AccessLevel.PRIVATE)
public class Cokleisli implements Function1,R>,
Transformable{
public final Function1,R> fn;
@Override
public R apply(Higher a) {
return fn.apply(a);
}
public Cokleisli mapFn(Function super R, ? extends R1> mapper){
return cokleisli(fn.andThen(mapper));
}
public Cokleisli map(Function super R, ? extends R1> mapper){
return mapFn(mapper);
}
public Cokleisli> fanout(Cokleisli f2) {
return product(f2);
}
public Cokleisli> product(Cokleisli f2) {
return cokleisli(fn.product(f2));
}
public static Cokleisli cokleisli(Function super Higher,? extends R> fn){
return new Cokleisli(Function1.narrow(fn));
}
public static Cokleisli of(Function super Higher,? extends R> fn){
return new Cokleisli(Function1.narrow(fn));
}
}