T
- The type contained on the Maybe withinpublic interface ReaderT<T,R>
extends org.reactivestreams.Publisher<T>
Modifier and Type | Method and Description |
---|---|
default <B> ReaderT<T,B> |
bind(java.util.function.Function<? super R,ReaderT<? extends T,B>> f)
Flat Map the wrapped Maybe
|
ReaderT<T,R> |
filter(java.util.function.Predicate<? super R> test)
Filter the wrapped Maybe
|
<B> ReaderT<B,R> |
flatMap(java.util.function.Function<? super T,? extends Reader<? extends B,R>> f) |
static <A,R> ReaderTValue<A,R> |
fromFuture(java.util.concurrent.CompletableFuture<Reader<A,R>> future) |
static <A,R> ReaderTSeq<A,R> |
fromIterable(java.lang.Iterable<Reader<A,R>> iterableOfEvals) |
static <A,R> ReaderTValue<A,R> |
fromIterableValue(java.lang.Iterable<Reader<A,R>> iterableOfEvals) |
static <A,R> ReaderTValue<A,R> |
fromOptional(java.util.Optional<Reader<A,R>> optional) |
static <A,R> ReaderTSeq<A,R> |
fromPublisher(org.reactivestreams.Publisher<Reader<A,R>> publisherOfEvals) |
static <A,R> ReaderTSeq<A,R> |
fromStream(java.util.stream.Stream<Reader<A,R>> streamOfEvals) |
static <A,R,V extends MonadicValue<Reader<A,R>>> |
fromValue(V monadicValue) |
static <T,U,R> java.util.function.Function<ReaderT<T,U>,ReaderT<T,R>> |
lift(java.util.function.Function<? super U,? extends R> fn)
Lift a function into one that accepts and returns an MaybeT This allows
multiple monad types to add functionality to existing functions and
methods
e.g.
|
static <T,U1,U2,R> |
lift2(java.util.function.BiFunction<? super U1,? super U2,? extends R> fn)
Lift a BiFunction into one that accepts and returns MaybeTs This allows
multiple monad types to add functionality to existing functions and
methods
e.g.
|
<B> ReaderT<T,B> |
map(java.util.function.Function<? super R,? extends B> f)
Map the wrapped Maybe
|
static <A,R> ReaderT<A,R> |
of(AnyM<Reader<A,R>> monads)
Construct an MaybeT from an AnyM that wraps a monad containing Maybes
|
ReaderTValue<T,R> |
peek(java.util.function.Consumer<? super R> peek)
Peek at the current value of the Maybe
|
AnyM<Reader<T,R>> |
unwrap() |
ReaderTValue<T,R> peek(java.util.function.Consumer<? super R> peek)
MaybeT.of(AnyM.fromStream(Maybe.of(10))
.peek(System.out::println);
//prints 10
peek
- Consumer to accept current value of MaybeReaderT<T,R> filter(java.util.function.Predicate<? super R> test)
MaybeT.of(AnyM.fromStream(Maybe.of(10))
.filter(t->t!=10);
//MaybeT<AnyM<Stream<Maybe.empty>>>
test
- Predicate to filter the wrapped Maybe<B> ReaderT<T,B> map(java.util.function.Function<? super R,? extends B> f)
MaybeT.of(AnyM.fromStream(Maybe.of(10))
.map(t->t=t+1);
//MaybeT<AnyM<Stream<Maybe[11]>>>
f
- Mapping function for the wrapped Maybedefault <B> ReaderT<T,B> bind(java.util.function.Function<? super R,ReaderT<? extends T,B>> f)
MaybeT.of(AnyM.fromStream(Maybe.of(10))
.bind(t->Maybe.empty();
//MaybeT<AnyM<Stream<Maybe.empty>>>
f
- FlatMap function<B> ReaderT<B,R> flatMap(java.util.function.Function<? super T,? extends Reader<? extends B,R>> f)
static <T,U,R> java.util.function.Function<ReaderT<T,U>,ReaderT<T,R>> lift(java.util.function.Function<? super U,? extends R> fn)
{ @code Functionadd2 = i -> i + 2; Function , MaybeT > optTAdd2 = MaybeT.lift(add2); Stream withNulls = Stream.of(1, 2, null); AnyM stream = AnyM.ofMonad(withNulls); AnyM > streamOpt = stream.map(Maybe::ofNullable); List results = optTAdd2.apply(MaybeT.of(streamOpt)).unwrap(). >> unwrap() .filter(Maybe::isPresent).map(Maybe::get).collect(Collectors.toList()); // Arrays.asList(3,4); }
fn
- Function to enhance with functionality from Maybe and another
monad typestatic <T,U1,U2,R> java.util.function.BiFunction<ReaderT<T,U1>,ReaderT<T,U2>,ReaderT<T,R>> lift2(java.util.function.BiFunction<? super U1,? super U2,? extends R> fn)
{ @code BiFunctionadd = (a, b) -> a + b; BiFunction , MaybeT , MaybeT > optTAdd2 = MaybeT.lift2(add); Stream withNulls = Stream.of(1, 2, null); AnyM stream = AnyM.ofMonad(withNulls); AnyM > streamOpt = stream.map(Maybe::ofNullable); CompletableFuture > two = CompletableFuture.supplyAsync(() -> Maybe.of(2)); AnyM > future = AnyM.ofMonad(two); List results = optTAdd2.apply(MaybeT.of(streamOpt), MaybeT.of(future)).unwrap() . >> unwrap().filter(Maybe::isPresent).map(Maybe::get) .collect(Collectors.toList()); // Arrays.asList(3,4); }
fn
- BiFunction to enhance with functionality from Maybe and
another monad typestatic <A,R> ReaderT<A,R> of(AnyM<Reader<A,R>> monads)
monads
- AnyM that contains a monad wrapping an Maybestatic <A,R> ReaderTSeq<A,R> fromIterable(java.lang.Iterable<Reader<A,R>> iterableOfEvals)
static <A,R> ReaderTSeq<A,R> fromStream(java.util.stream.Stream<Reader<A,R>> streamOfEvals)
static <A,R> ReaderTSeq<A,R> fromPublisher(org.reactivestreams.Publisher<Reader<A,R>> publisherOfEvals)
static <A,R,V extends MonadicValue<Reader<A,R>>> ReaderTValue<A,R> fromValue(V monadicValue)
static <A,R> ReaderTValue<A,R> fromOptional(java.util.Optional<Reader<A,R>> optional)
static <A,R> ReaderTValue<A,R> fromFuture(java.util.concurrent.CompletableFuture<Reader<A,R>> future)
static <A,R> ReaderTValue<A,R> fromIterableValue(java.lang.Iterable<Reader<A,R>> iterableOfEvals)