mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-18 14:50:56 +00:00
update OreAddon to use do notation
This commit is contained in:
+2
-1
@@ -1,8 +1,9 @@
|
||||
package com.dfsek.terra.addons.manifest.api;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Init;
|
||||
import com.dfsek.terra.api.util.function.monad.Monad;
|
||||
|
||||
|
||||
public interface MonadAddonInitializer {
|
||||
Init<?> initialize();
|
||||
Monad<?, Init<?>> initialize();
|
||||
}
|
||||
|
||||
+44
@@ -32,6 +32,12 @@ public final class Do {
|
||||
.bind(bind2.apply(t)));
|
||||
}
|
||||
|
||||
public static <T, U, V, M extends Monad<?, M>> Monad<V, M> with(Monad<T, M> monad,
|
||||
Monad<U, M> monad2,
|
||||
Function2<T, U, Monad<V, M>> bind2) {
|
||||
return with(monad, Function1.constant(monad2), bind2);
|
||||
}
|
||||
|
||||
public static <T, U, V, W, M extends Monad<?, M>> Monad<W, M> with(Monad<T, M> monad,
|
||||
Function1<T, Monad<U, M>> bind,
|
||||
Function2<T, U, Monad<V, M>> bind2,
|
||||
@@ -45,6 +51,20 @@ public final class Do {
|
||||
.apply(u)));
|
||||
}
|
||||
|
||||
public static <T, U, V, W, M extends Monad<?, M>> Monad<W, M> with(Monad<T, M> monad,
|
||||
Monad<U, M> monad2,
|
||||
Function2<T, U, Monad<V, M>> bind2,
|
||||
Function3<T, U, V, Monad<W, M>> bind3) {
|
||||
return with(monad, Function1.constant(monad2), bind2, bind3);
|
||||
}
|
||||
|
||||
public static <T, U, V, W, M extends Monad<?, M>> Monad<W, M> with(Monad<T, M> monad,
|
||||
Monad<U, M> monad2,
|
||||
Monad<V, M> monad3,
|
||||
Function3<T, U, V, Monad<W, M>> bind3) {
|
||||
return with(monad, monad2, Function2.constant(monad3), bind3);
|
||||
}
|
||||
|
||||
public static <T, U, V, W, X, M extends Monad<?, M>> Monad<X, M> with(Monad<T, M> monad,
|
||||
Function1<T, Monad<U, M>> bind,
|
||||
Function2<T, U, Monad<V, M>> bind2,
|
||||
@@ -61,4 +81,28 @@ public final class Do {
|
||||
.apply(v)))
|
||||
.apply(u)));
|
||||
}
|
||||
|
||||
public static <T, U, V, W, X, M extends Monad<?, M>> Monad<X, M> with(Monad<T, M> monad,
|
||||
Monad<U, M> monad2,
|
||||
Function2<T, U, Monad<V, M>> bind2,
|
||||
Function3<T, U, V, Monad<W, M>> bind3,
|
||||
Function4<T, U, V, W, Monad<X, M>> bind4) {
|
||||
return with(monad, Function1.constant(monad2), bind2, bind3, bind4);
|
||||
}
|
||||
|
||||
public static <T, U, V, W, X, M extends Monad<?, M>> Monad<X, M> with(Monad<T, M> monad,
|
||||
Monad<U, M> monad2,
|
||||
Monad<V, M> monad3,
|
||||
Function3<T, U, V, Monad<W, M>> bind3,
|
||||
Function4<T, U, V, W, Monad<X, M>> bind4) {
|
||||
return with(monad, monad2, Function2.constant(monad3), bind3, bind4);
|
||||
}
|
||||
|
||||
public static <T, U, V, W, X, M extends Monad<?, M>> Monad<X, M> with(Monad<T, M> monad,
|
||||
Monad<U, M> monad2,
|
||||
Monad<V, M> monad3,
|
||||
Monad<W, M> monad4,
|
||||
Function4<T, U, V, W, Monad<X, M>> bind4) {
|
||||
return with(monad, monad2, monad3, Function3.constant(monad4), bind4);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -34,6 +34,10 @@ public class Init<T> implements Monad<T, Init<?>> {
|
||||
|
||||
@Override
|
||||
public <U> Monad<U, Init<?>> pure(U u) {
|
||||
return of(Functions.constant(u));
|
||||
return ofPure(u);
|
||||
}
|
||||
|
||||
public static <T> Init<T> ofPure(T t) {
|
||||
return of(Functions.constant(t));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ package com.dfsek.terra.addons.manifest.impl;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.addons.manifest.api.MonadAddonInitializer;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Init;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.inject.Injector;
|
||||
@@ -34,7 +35,7 @@ public abstract class Initializer {
|
||||
|
||||
@Override
|
||||
public void initialize(InitInfo info) {
|
||||
addon.initialize().apply(info);
|
||||
((Init<?>) addon.initialize()).apply(info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user