fj.Effect Maven / Gradle / Ivy
package fj;
import fj.function.Effect0;
import fj.function.Effect1;
import fj.function.Effect2;
import fj.function.Effect3;
import fj.function.Effect4;
import fj.function.Effect5;
import fj.function.Effect6;
import fj.function.Effect7;
import fj.function.Effect8;
import static fj.Unit.unit;
/**
* Represents a side-effect.
*
* @version %build.number%
*/
public class Effect {
private Effect() {}
public static P1 f(Effect0 e) {
return P.lazy(() -> {
e.f();
return unit();
});
}
/**
* Returns a function for the given effect.
*
* @return The function using the given effect.
*/
public static final F f(Effect1 e1) {
return a -> {
e1.f(a);
return unit();
};
}
public static F2 f(Effect2 e) {
return (a, b) -> {
e.f(a, b);
return unit();
};
}
public static F3 f(Effect3 e) {
return (a, b, c) -> {
e.f(a, b, c);
return unit();
};
}
public static F4 f(Effect4 e) {
return (a, b, c, d) -> {
e.f(a, b, c, d);
return unit();
};
}
public static F5 f(Effect5 z) {
return (a, b, c, d, e) -> {
z.f(a, b, c, d, e);
return unit();
};
}
public static F6 f(Effect6 z) {
return (a, b, c, d, e, f) -> {
z.f(a, b, c, d, e, f);
return unit();
};
}
public static F7 f(Effect7 z) {
return (a, b, c, d, e, f, g) -> {
z.f(a, b, c, d, e, f, g);
return unit();
};
}
public static F8 f(Effect8 z) {
return (a, b, c, d, e, f, g, h) -> {
z.f(a, b, c, d, e, f, g, h);
return unit();
};
}
/**
* A contra-variant functor on effect.
*
* @param f The function to map over the effect.
* @return An effect after a contra-variant map.
*/
public static final Effect1 contramap(Effect1 e1, final F f) {
return b -> e1.f(f.f(b));
}
public static Effect1 lazy(final F f) {
return a -> f.f(a);
}
// public static void f(Effect1 )
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy