package bjc.typeclasses; import java.util.function.Function; /** * Represents an applicative * @author bjcul * * @param The contained type * @param The self type */ public interface Applicative> extends FunctorX { /** * Create an applicative from a value * * @param The type of the value * * @param val The value * * @return An applicative containing the given value */ Applicative pure(B val); /** * Apply the given applicative * * @param The type of the result * * @param func An applicative containing a function * * @return An applicative containing the result of applying the function */ Applicative app(Applicative, App> func); @Override default FunctorX fmap(Function fn) { return app(pure(fn)); } }