com.shapesecurity.functional.data.FreePairingMonoid Maven / Gradle / Ivy
package com.shapesecurity.functional.data;
import com.shapesecurity.functional.Pair;
import org.jetbrains.annotations.NotNull;
public final class FreePairingMonoid implements Monoid> {
@NotNull
private final Monoid monoidA;
@NotNull
private final Monoid monoidB;
public FreePairingMonoid(@NotNull Monoid monoidA, @NotNull Monoid monoidB) {
this.monoidA = monoidA;
this.monoidB = monoidB;
}
@NotNull
@Override
public Pair identity() {
return new Pair<>(this.monoidA.identity(), this.monoidB.identity());
}
@NotNull
@Override
public Pair append(Pair a, Pair b) {
return new Pair<>(monoidA.append(a.left, b.left), monoidB.append(a.right, b.right));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy