![JAR search and dependency download from the Maven repository](/logo.png)
javaslang.algebra.Semigroup Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javaslang-pure Show documentation
Show all versions of javaslang-pure Show documentation
A purely functional layer above Javaslang.
The newest version!
/* / \____ _ _ ____ ______ / \ ____ __ _______
* / / \/ \ / \/ \ / /\__\/ // \/ \ // /\__\ JΛVΛSLΛNG
* _/ / /\ \ \/ / /\ \\__\\ \ // /\ \ /\\/ \ /__\ \ Copyright 2014-2017 Javaslang, http://javaslang.io
* /___/\_/ \_/\____/\_/ \_/\__\/__/\__\_/ \_// \__/\_____/ Licensed under the Apache License, Version 2.0
*/
package javaslang.algebra;
/**
* A Semigroup is a type with an associative binary operation {@linkplain #combine(Object, Object)}.
* Given a type {@code A}, instances of Semigroup should satisfy the following law:
*
* - Associativity: {@code combine(combine(x,y),z) == combine(x,combine(y,z))} for any {@code x,y,z} of type
* {@code A}.
*
* Note: Technically a Semigroup is the same as a {@code java.util.function.BiFunction}. Introducing this new type
* clarifies that the operation {@code combine} is associative.
*
* @param A type.
* @author Daniel Dietrich
* @since 1.1.0
*/
@FunctionalInterface
public interface Semigroup {
/**
* Combines two elements of the same type, which is also returned.
*
* @param a1 An element
* @param a2 Another element
* @return The combination of a1 and a2
*/
A combine(A a1, A a2);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy