本文整理汇总了Java中org.derive4j.hkt.TypeEq类的典型用法代码示例。如果您正苦于以下问题:Java TypeEq类的具体用法?Java TypeEq怎么用?Java TypeEq使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypeEq类属于org.derive4j.hkt包,在下文中一共展示了TypeEq类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: of
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
static <K, S, E, R> StreamIOAlgebra<K, S, E, R> of(EventStream<K, S, E> eventStream) {
return new StreamIOAlgebra<K, S, E, R>() {
@Override public IO<R> Read(Option<S> fromSeq, Fold<Event<K, S, E>, R> streamFold) {
return eventStream.read(fromSeq, streamFold);
}
@Override public IO<R> Latest(TypeEq<Option<Event<K, S, E>>, R> resultType) {
return eventStream.latest().map(resultType::coerce);
}
@Override public <Q> StreamIOAlgebra<K, S, E, Q> vary() {
return of(eventStream);
}
};
}
示例2: testNondeterminism
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
@Test
@SuppressWarnings("UnusedAssignment")
public void testNondeterminism() {
List<String> results = asList(
Do_.<List.µ>do_()
.pushM(List.range(1, 1, 3))
.pushM(List.range(1, 1, 3))
.map2(
TypeEq.refl(),
(Integer a, Integer b) ->
"" + a + " x " + b + " = " + (a*b)
)
.runWithResultNoTailRec(TypeEq.refl(), List.monadPlus)
);
assertThat(results).containsExactly(
"1 x 1 = 1", "1 x 2 = 2", "1 x 3 = 3",
"2 x 1 = 2", "2 x 2 = 4", "2 x 3 = 6",
"3 x 1 = 3", "3 x 2 = 6", "3 x 3 = 9"
);
}
示例3: testBind
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
@Test
public void testBind() {
Either<String, Integer> handSum = asEither(
Do_.<__<Either.µ,String>>do_()
.push(6)
.push(7)
.pushBind2(TypeEq.refl(), (Integer a, Integer b) -> {
int r = a + b;
if (r > 10) {
return Either.<String, Integer>Left("Not enough fingers!");
} else {
return Either.<String, Integer>Right(r);
}
})
.runWithResult(TypeEq.refl(), Either.monad())
);
assertEquals("Left(Not enough fingers!)", handSum.toString());
}
示例4: GenCode
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
GenCode(Elements elts, Types types, Filer filer, TypeElement elt) {
Elts = elts;
Types = types;
Filer = filer;
__Elt = elt;
TypeEqElt = Elts.getTypeElement(TypeEq.class.getName());
}
示例5: WriteEvents
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
default WStreamAction<K, S, E, WriteResult<K, S, E>> WriteEvents(Option<S> expectedSeq, Instant time,
Iterable<E> events) {
return new WStreamAction<K, S, E, WriteResult<K, S, E>>() {
@Override public <X> X eval(Algebra<K, S, E, WriteResult<K, S, E>, X> interpreter) {
return interpreter.Write(expectedSeq, time, events, TypeEq.refl());
}
};
}
示例6: GetLatestEvent
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
default StreamAction<K, S, E, Option<Event<K, S, E>>> GetLatestEvent() {
return new StreamAction<K, S, E, Option<Event<K, S, E>>>() {
@Override public <X> X eval(Algebra<K, S, E, Option<Event<K, S, E>>, X> interpreter) {
return interpreter.Latest(TypeEq.refl());
}
};
}
示例7: GetSnapshot
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
default SnapshotAction<S, V, Snapshot<S, V>> GetSnapshot(SequenceQuery<S> sequence) {
return new SnapshotAction<S, V, Snapshot<S, V>>() {
@Override public <X> X eval(Algebra<S, V, Snapshot<S, V>, X> interpreter) {
return interpreter.Get(sequence, TypeEq.refl());
}
};
}
示例8: PutSnapshot
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
default SnapshotAction<S, V, Snapshot<S, V>> PutSnapshot(Snapshot<S, V> snapshot, SnapshotStoreMode mode) {
return new SnapshotAction<S, V, Snapshot<S, V>>() {
@Override public <X> X eval(Algebra<S, V, Snapshot<S, V>, X> interpreter) {
return interpreter.Put(snapshot, mode, TypeEq.refl());
}
};
}
示例9: Get
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
@Override default X Get(SequenceQuery<S> sequence, TypeEq<Snapshot<S, V>, R> resultType) {
return snapshotAlgebra().Get(sequence, resultType);
}
示例10: Put
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
@Override default X Put(Snapshot<S, V> snapshot, SnapshotStoreMode mode, TypeEq<Snapshot<S, V>, R> resultType) {
return snapshotAlgebra().Put(snapshot, mode, resultType);
}
示例11: Write
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
@Override default X Write(Option<S> expectedSeq, Instant time, Iterable<E> events, TypeEq<WriteResult<K, S, E>, R> resultType) {
return wStreamAlgebra().Write(expectedSeq, time, events, resultType);
}
示例12: Latest
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
@Override default X Latest(TypeEq<Option<Event<K, S, E>>, R> resultType) {
return wStreamAlgebra().Latest(resultType);
}
示例13: First
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
private First(FreeArrow<F,ARR,B,C> a, TypeEq<E,T2<B,D>> typeEq1, TypeEq<T2<C,D>,G> typeEq2) {
this._a = a;
this._typeEq1 = typeEq1;
this._typeEq2 = typeEq2;
}
示例14: create
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
public static <F,ARR,B,C,D> First<F,ARR,B,C,D,T2<B,D>,T2<C,D>> create(FreeArrow<F,ARR,B,C> a) {
return new First<>(a, TypeEq.refl(), TypeEq.refl());
}
示例15: typeEq1
import org.derive4j.hkt.TypeEq; //导入依赖的package包/类
public TypeEq<E,T2<B,D>> typeEq1() {
return _typeEq1;
}