All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cyclops.arrow.Cokleisli Maven / Gradle / Ivy

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 mapper){
        return cokleisli(fn.andThen(mapper));
    }
    public  Cokleisli map(Function 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,? extends R> fn){
        return new Cokleisli(Function1.narrow(fn));
    }
    public static  Cokleisli of(Function,? extends R> fn){
        return new Cokleisli(Function1.narrow(fn));
    }




}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy