Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.lang.model.type.NullType;
- import java.util.function.Function;
- public 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);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement