T
- The type contained on the Maybe withinpublic class ReaderTSeq<T,R>
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
R |
apply(T t,
Monoid<R> combiner) |
boolean |
equals(java.lang.Object o) |
<B> ReaderTSeq<T,B> |
flatMap(java.util.function.Function<? super R,? extends Reader<T,B>> f) |
<B> ReaderTSeq<T,B> |
flatMapT(java.util.function.Function<? super R,ReaderTSeq<T,B>> mapper)
Flat Map the wrapped Reader
|
static <T,A> ReaderTSeq<T,A> |
fromAnyM(AnyMSeq<java.util.function.Function<T,A>> anyM)
|
int |
hashCode() |
static <T,U,R> java.util.function.Function<ReaderTSeq<T,U>,ReaderTSeq<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> ReaderTSeq<T,B> |
map(java.util.function.Function<? super R,? extends B> f)
Map the wrapped Maybe
|
static <T,A> ReaderTSeq<T,A> |
of(AnyMSeq<Reader<T,A>> monads)
Construct an MaybeT from an AnyM that wraps a monad containing Maybes
|
ReaderTSeq<T,R> |
peek(java.util.function.Consumer<? super R> peek)
Peek at the current value of the Maybe
|
ReactiveSeq<R> |
streamApply(T t) |
java.lang.String |
toString() |
AnyMSeq<Reader<T,R>> |
unwrap() |
public ReaderTSeq<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 Maybepublic <B> ReaderTSeq<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<AnyMSeq<Stream<Maybe[11]>>>
f
- Mapping function for the wrapped Maybepublic <B> ReaderTSeq<T,B> flatMapT(java.util.function.Function<? super R,ReaderTSeq<T,B>> mapper)
mapper
- FlatMap functionpublic <B> ReaderTSeq<T,B> flatMap(java.util.function.Function<? super R,? extends Reader<T,B>> f)
public static <T,U,R> java.util.function.Function<ReaderTSeq<T,U>,ReaderTSeq<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); AnyMSeq stream = AnyM.ofMonad(withNulls); AnyMSeq > 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 typepublic static <T,U1,U2,R> java.util.function.BiFunction<ReaderTSeq<T,U1>,ReaderTSeq<T,U2>,ReaderTSeq<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); AnyMSeq stream = AnyM.ofMonad(withNulls); AnyMSeq > streamOpt = stream.map(Maybe::ofNullable); CompletableFuture > two = CompletableFuture.supplyAsync(() -> Maybe.of(2)); AnyMSeq > 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 typepublic static <T,A> ReaderTSeq<T,A> fromAnyM(AnyMSeq<java.util.function.Function<T,A>> anyM)
anyM
- AnyM that doesn't contain a monad wrapping an Maybepublic static <T,A> ReaderTSeq<T,A> of(AnyMSeq<Reader<T,A>> monads)
monads
- AnyM that contains a monad wrapping an Maybepublic java.lang.String toString()
toString
in class java.lang.Object
public ReactiveSeq<R> streamApply(T t)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object