Constructor and Description |
---|
Instances() |
Modifier and Type | Method and Description |
---|---|
static <T> Foldable<QueueX.µ> |
foldable()
int sum = Queues.foldable()
.foldLeft(0, (a,b)->a+b, QueueX.of(1,2,3,4)));
//10
|
static <T,R> Functor<QueueX.µ> |
functor()
Transform a queue, mulitplying every element by 2
|
static <T,R> Monad<QueueX.µ> |
monad()
import static com.aol.cyclops.hkt.jdk.QueueX.widen;
QueueX<Integer> queue = Queues.monad()
.flatMap(i->widen(QueueX.range(0,i)), widen(QueueX.of(1,2,3)))
.convert(QueueX::narrowK);
|
static <T> MonadPlus<QueueX.µ> |
monadPlus()
QueueX<Integer> queue = Queues.<Integer>monadPlus()
.plus(QueueX.of()), QueueX.of(10)))
.convert(QueueX::narrowK);
//QueueX.of(10))
|
static <T> MonadPlus<QueueX.µ> |
monadPlus(Monoid<QueueX<T>> m)
Monoid<QueueX<Integer>> m = Monoid.of(QueueX.of()), (a,b)->a.isEmpty() ? b : a);
QueueX<Integer> queue = Queues.<Integer>monadPlus(m)
.plus(QueueX.of(5)), QueueX.of(10)))
.convert(QueueX::narrowK);
//QueueX.of(5))
|
static <T,R> MonadZero<QueueX.µ> |
monadZero()
QueueX<String> queue = Queues.unit()
.unit("hello")
.apply(h->Queues.monadZero().filter((String t)->t.startsWith("he"), h))
.convert(QueueX::narrowK);
//QueueX.of("hello"));
|
static <C2,T> Traverse<QueueX.µ> |
traverse() |
static <T> Pure<QueueX.µ> |
unit()
QueueX<String> queue = Queues.unit()
.unit("hello")
.convert(QueueX::narrowK);
//QueueX.of("hello"))
|
static <T,R> Applicative<QueueX.µ> |
zippingApplicative()
import static com.aol.cyclops.hkt.jdk.QueueX.widen;
import static com.aol.cyclops.util.function.Lambda.l1;
import static java.util.QueueX.of;
Queues.zippingApplicative()
.ap(widen(asQueue(l1(this::multiplyByTwo))),widen(asQueue(1,2,3)));
//[2,4,6]
|
public static <T,R> Functor<QueueX.µ> functor()
QueueX<Integer> queue = Queues.functor().map(i->i*2, QueueX.of(1,2,3));
//[2,4,6]
An example fluent api working with Queues
QueueX<Integer> queue = Queues.unit()
.unit("hello")
.apply(h->Queues.functor().map((String v) ->v.length(), h))
.convert(QueueX::narrowK);
public static <T> Pure<QueueX.µ> unit()
QueueX<String> queue = Queues.unit()
.unit("hello")
.convert(QueueX::narrowK);
//QueueX.of("hello"))
public static <T,R> Applicative<QueueX.µ> zippingApplicative()
import static com.aol.cyclops.hkt.jdk.QueueX.widen;
import static com.aol.cyclops.util.function.Lambda.l1;
import static java.util.QueueX.of;
Queues.zippingApplicative()
.ap(widen(asQueue(l1(this::multiplyByTwo))),widen(asQueue(1,2,3)));
//[2,4,6]
Example fluent API
QueueX<Function<Integer,Integer>> queueFn =Queues.unit()
.unit(Lambda.l1((Integer i) ->i*2))
.convert(QueueX::narrowK);
QueueX<Integer> queue = Queues.unit()
.unit("hello")
.apply(h->Queues.functor().map((String v) ->v.length(), h))
.apply(h->Queues.zippingApplicative().ap(queueFn, h))
.convert(QueueX::narrowK);
//QueueX.of("hello".length()*2))
public static <T,R> Monad<QueueX.µ> monad()
import static com.aol.cyclops.hkt.jdk.QueueX.widen;
QueueX<Integer> queue = Queues.monad()
.flatMap(i->widen(QueueX.range(0,i)), widen(QueueX.of(1,2,3)))
.convert(QueueX::narrowK);
Example fluent API
QueueX<Integer> queue = Queues.unit()
.unit("hello")
.apply(h->Queues.monad().flatMap((String v) ->Queues.unit().unit(v.length()), h))
.convert(QueueX::narrowK);
//QueueX.of("hello".length())
public static <T,R> MonadZero<QueueX.µ> monadZero()
QueueX<String> queue = Queues.unit()
.unit("hello")
.apply(h->Queues.monadZero().filter((String t)->t.startsWith("he"), h))
.convert(QueueX::narrowK);
//QueueX.of("hello"));
public static <T> MonadPlus<QueueX.µ> monadPlus()
QueueX<Integer> queue = Queues.<Integer>monadPlus()
.plus(QueueX.of()), QueueX.of(10)))
.convert(QueueX::narrowK);
//QueueX.of(10))
public static <T> MonadPlus<QueueX.µ> monadPlus(Monoid<QueueX<T>> m)
Monoid<QueueX<Integer>> m = Monoid.of(QueueX.of()), (a,b)->a.isEmpty() ? b : a);
QueueX<Integer> queue = Queues.<Integer>monadPlus(m)
.plus(QueueX.of(5)), QueueX.of(10)))
.convert(QueueX::narrowK);
//QueueX.of(5))
m
- Monoid toNested use for combining Queuespublic static <C2,T> Traverse<QueueX.µ> traverse()