com.jnape.palatable.lambda.functions.specialized.Lift Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lambda Show documentation
Show all versions of lambda Show documentation
Functional patterns for Java
package com.jnape.palatable.lambda.functions.specialized;
import com.jnape.palatable.lambda.internal.Runtime;
import com.jnape.palatable.lambda.monad.MonadBase;
import com.jnape.palatable.lambda.monad.MonadRec;
import static com.jnape.palatable.lambda.functions.builtin.fn1.Downcast.downcast;
/**
* Generalized, portable lifting operation for lifting a {@link MonadRec} into a {@link MonadBase}.
*
* @param the {@link MonadBase} to lift into
*/
@FunctionalInterface
public interface Lift> {
> MonadBase checkedApply(MonadRec ga)
throws Throwable;
default , MBA extends MonadBase> MBA apply(MonadRec ma) {
try {
return downcast(checkedApply(ma));
} catch (Throwable t) {
throw Runtime.throwChecked(t);
}
}
/**
* Static method to aid inference.
*
* @param lift the {@link Lift}
* @param the {@link MonadBase} to lift into
* @return the {@link Lift}
*/
static > Lift lift(Lift lift) {
return lift;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy