Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package skittles.monad.knowsimpl;
- import javax.lang.model.type.NullType;
- import java.util.function.Function;
- public abstract class Monad<T, E> {
- private final T value;
- public Monad(T value) {
- this.value = value;
- }
- public T extract() {
- return this.value;
- }
- public Monad<NullType, E> bind(Function<T, Monad<NullType, E>> f) {
- return f.apply(value);
- }
- public Monad<NullType, E> sequencer(Monad<NullType, E> b) {
- return bind(__ -> b);
- }
- public static <T, E> Monad<T, E> create(T value) {
- return new Kek<>(value);
- }
- }
- package skittles.monad.knowsimpl;
- public class Kek<T, E> extends Monad<T, E> {
- public Kek(T value) {
- super(value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement