fj.F1W Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionaljava Show documentation
Show all versions of functionaljava Show documentation
Functional Java is an open source library that supports closures for the Java programming language
package fj;
import fj.control.parallel.Actor;
import fj.control.parallel.Promise;
import fj.control.parallel.Strategy;
import fj.data.*;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
import java.util.concurrent.*;
/**
* Created by MarkPerry on 22/01/2015.
*/
public abstract class F1W implements F {
/**
* Function composition
*
* @param g A function to compose with this one.
* @return The composed function such that this function is applied last.
*/
public F1W o(final F g) {
return lift(F1Functions.o(this, g));
}
/**
* First-class function composition
*
* @return A function that composes this function with another.
*/
public F1W, F> o() {
return lift(F1Functions.o(this));
}
/**
* Function composition flipped.
*
* @param g A function with which to compose this one.
* @return The composed function such that this function is applied first.
*/
@SuppressWarnings({"unchecked"})
public F1W andThen(final F g) {
return lift(F1Functions.andThen(this, g));
}
/**
* First-class composition flipped.
*
* @return A function that invokes this function and then a given function on the result.
*/
public F1W, F> andThen() {
return lift( F1Functions.andThen(this));
}
/**
* Binds a given function across this function (Reader Monad).
*
* @param g A function that takes the return value of this function as an argument, yielding a new function.
* @return A function that invokes this function on its argument and then the given function on the result.
*/
public F1W bind(final F> g) {
return lift(F1Functions.bind(this, g));
}
/**
* First-class function binding.
*
* @return A function that binds another function across this function.
*/
public F1W>, F> bind() {
return lift(F1Functions.bind(this));
}
/**
* Function application in an environment (Applicative Functor).
*
* @param g A function with the same argument type as this function, yielding a function that takes the return
* value of this function.
* @return A new function that invokes the given function on its argument, yielding a new function that is then
* applied to the result of applying this function to the argument.
*/
public F1W apply(final F> g) {
return lift(F1Functions.apply(this, g));
}
/**
* First-class function application in an environment.
*
* @return A function that applies a given function within the environment of this function.
*/
public F1W>, F> apply() {
return lift(F1Functions.apply(this));
}
/**
* Applies this function over the arguments of another function.
*
* @param g The function over whose arguments to apply this function.
* @return A new function that invokes this function on its arguments before invoking the given function.
*/
public F1W> on(final F> g) {
return lift(F1Functions.on(this, g));
}
/**
* Applies this function over the arguments of another function.
*
* @return A function that applies this function over the arguments of another function.
*/
public F1W>, F>> on() {
return lift(F1Functions.on(this));
}
/**
* Promotes this function so that it returns its result in a product-1. Kleisli arrow for P1.
*
* @return This function promoted to return its result in a product-1.
*/
public F1W> lazy() {
return lift(F1Functions.lazy(this));
}
/**
* Partial application.
*
* @param a The A
to which to apply this function.
* @return The function partially applied to the given argument to return a lazy value.
*/
public P1 lazy(final A a) {
return F1Functions.f(this, a);
}
/**
* Promotes this function to map over a product-1.
*
* @return This function promoted to map over a product-1.
*/
public F1W, P1> mapP1() {
return lift(F1Functions.mapP1(this));
}
/**
* Promotes this function so that it returns its result in an Option. Kleisli arrow for Option.
*
* @return This function promoted to return its result in an Option.
*/
public F1W> optionK() {
return lift(F1Functions.optionK(this));
}
/**
* Promotes this function to map over an optional value.
*
* @return This function promoted to map over an optional value.
*/
public F1W