-
-
Notifications
You must be signed in to change notification settings - Fork 413
/
Semigroup.cs
25 lines (22 loc) · 804 Bytes
/
Semigroup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System.Diagnostics.Contracts;
namespace LanguageExt.Traits;
public interface Semigroup<A>
where A : Semigroup<A>
{
/// <summary>
/// An associative binary operation.
/// </summary>
/// <param name="this">The first operand to the operation</param>
/// <param name="rhs">The second operand to the operation</param>
/// <returns>The result of the operation</returns>
[Pure]
public A Combine(A rhs);
/// <summary>
/// An associative binary operation.
/// </summary>
/// <param name="lhs">The first operand to the operation</param>
/// <param name="rhs">The second operand to the operation</param>
/// <returns>The result of the operation</returns>
public static virtual A operator +(A lhs, A rhs) =>
lhs.Combine(rhs);
}