pub trait Semigroup<'b> {
// Required method
fn append<'a, ClonableFnBrand: 'a + 'b + ClonableFn>(
a: Self,
) -> ApplyFn<'a, ClonableFnBrand, Self, Self>
where Self: Sized,
'b: 'a;
}
Expand description
A type class for semigroups.
A Semigroup
is a set equipped with an associative binary operation.
In functional programming, semigroups are useful for combining values in a consistent way. They form the basis for more complex structures like monoids.
§Laws
Semigroup instances must satisfy the associative law:
- Associativity:
append(append(a)(b))(c) = append(a)(append(b)(c))
.
Required Methods§
Sourcefn append<'a, ClonableFnBrand: 'a + 'b + ClonableFn>(
a: Self,
) -> ApplyFn<'a, ClonableFnBrand, Self, Self>where
Self: Sized,
'b: 'a,
fn append<'a, ClonableFnBrand: 'a + 'b + ClonableFn>(
a: Self,
) -> ApplyFn<'a, ClonableFnBrand, Self, Self>where
Self: Sized,
'b: 'a,
Implementations on Foreign Types§
Source§impl<'b> Semigroup<'b> for String
impl<'b> Semigroup<'b> for String
Source§fn append<'a, ClonableFnBrand: 'a + 'b + ClonableFn>(
a: Self,
) -> ApplyFn<'a, ClonableFnBrand, Self, Self>where
Self: Sized,
'b: 'a,
fn append<'a, ClonableFnBrand: 'a + 'b + ClonableFn>(
a: Self,
) -> ApplyFn<'a, ClonableFnBrand, Self, Self>where
Self: Sized,
'b: 'a,
§Examples
use fp_library::{brands::RcFnBrand, functions::append};
use std::rc::Rc;
assert_eq!(
append::<RcFnBrand, String>("Hello, ".to_string())("World!".to_string()),
"Hello, World!"
);