#[non_exhaustive]pub struct IndexedCoproduct<K: ArrayKind, F> {
pub sources: FiniteFunction<K>,
pub values: F,
}Expand description
A finite coproduct of arrows of type A.
Pragmatically, it’s a segmented array
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.sources: FiniteFunction<K>A [‘FiniteFunction’] whose sum is the length of values, and whose target is sum + 1.
values: FThe concatenation of all arrays in the coproduct.
Implementations§
Source§impl<K: ArrayKind, F: Clone + HasLen<K>> IndexedCoproduct<K, F>
impl<K: ArrayKind, F: Clone + HasLen<K>> IndexedCoproduct<K, F>
Sourcepub fn new(sources: FiniteFunction<K>, values: F) -> Option<Self>
pub fn new(sources: FiniteFunction<K>, values: F) -> Option<Self>
Create a new IndexedCoproduct from a FiniteFunction whose target is the sum of its elements. This condition is checked by summing the array.
Sourcepub fn from_semifinite(
sources: SemifiniteFunction<K, K::I>,
values: F,
) -> Option<Self>
pub fn from_semifinite( sources: SemifiniteFunction<K, K::I>, values: F, ) -> Option<Self>
Create a IndexedCoproduct from an array of sources by computing their sum to create a
FiniteFunction.
Source§impl<K: ArrayKind, F: Clone + HasLen<K>> IndexedCoproduct<K, F>
impl<K: ArrayKind, F: Clone + HasLen<K>> IndexedCoproduct<K, F>
Sourcepub fn singleton(values: F) -> Self
pub fn singleton(values: F) -> Self
Construct a segmented array with a single segment containing values.
Sourcepub fn elements(values: F) -> Self
pub fn elements(values: F) -> Self
Construct a segmented array with values.len() segments, each containing a single element.
pub fn len(&self) -> K::I
Sourcepub fn flatmap_sources<G: Clone>(
&self,
other: &IndexedCoproduct<K, G>,
) -> IndexedCoproduct<K, G>
pub fn flatmap_sources<G: Clone>( &self, other: &IndexedCoproduct<K, G>, ) -> IndexedCoproduct<K, G>
Like IndexedCoproduct::flatmap, but where the values of other are already mapped.
Conceptually, suppose we have
self : [[T]]
other: [[U]]where other defines a sublist for each element of join(self).
Then self.flatmap_sources(other) merges sublists of other using the sources of self.
Source§impl<K: ArrayKind> IndexedCoproduct<K, FiniteFunction<K>>
impl<K: ArrayKind> IndexedCoproduct<K, FiniteFunction<K>>
Sourcepub fn initial(target: K::I) -> Self
pub fn initial(target: K::I) -> Self
The initial object, i.e., the finite coproduct indexed by the empty set
Note that the target of sources must be zero for laws to work here.
pub fn tensor( &self, other: &IndexedCoproduct<K, FiniteFunction<K>>, ) -> IndexedCoproduct<K, FiniteFunction<K>>
Sourcepub fn map_values(&self, x: &FiniteFunction<K>) -> Option<Self>
pub fn map_values(&self, x: &FiniteFunction<K>) -> Option<Self>
Map the values array of an indexed coproduct, leaving the sources unchanged.
Given an indexed coproduct
Σ_{i ∈ I} f_i : Σ_{i ∈ I} A_i → Band a finite function x : B → C,
return a new IndexedCoproduct representing
Σ_{i ∈ I} (f_i ; x) : Σ_{i ∈ I} A_i → CReturns None if x.source() != B.
Sourcepub fn map_semifinite<T>(
&self,
x: &SemifiniteFunction<K, T>,
) -> Option<IndexedCoproduct<K, SemifiniteFunction<K, T>>>
pub fn map_semifinite<T>( &self, x: &SemifiniteFunction<K, T>, ) -> Option<IndexedCoproduct<K, SemifiniteFunction<K, T>>>
Same as map_values, but for SemifiniteFunction.
Sourcepub fn flatmap(&self, other: &Self) -> Self
pub fn flatmap(&self, other: &Self) -> Self
Compose two IndexedCoproduct thought of as lists-of-lists.
Given
self : Σ_{a ∈ A} s(a) → B aka A → B*
other : Σ_{b ∈ B} s(b) → C aka B → C*we obtain
self.flatmap(other) : Σ_{a ∈ A} s(a) → C aka A → C*Source§impl<K: ArrayKind, F> IndexedCoproduct<K, F>
impl<K: ArrayKind, F> IndexedCoproduct<K, F>
pub fn coproduct(&self, other: &Self) -> Option<Self>
Sourcepub fn map_indexes(&self, x: &FiniteFunction<K>) -> Option<Self>
pub fn map_indexes(&self, x: &FiniteFunction<K>) -> Option<Self>
Given an IndexedCoproduct of SemifiniteFunction:
Σ_{i ∈ X} f_i : Σ_{i ∈ X} A_i → Band a finite function x : W → X
Return a new IndexedCoproduct representing
Σ_{i ∈ W} f_{x(i)} : Σ_{i ∈ W} A_{x(i)} → BSourcepub fn indexed_values(&self, x: &FiniteFunction<K>) -> Option<F>
pub fn indexed_values(&self, x: &FiniteFunction<K>) -> Option<F>
Like Self::map_indexes but only returns the values array.
Source§impl<T> IndexedCoproduct<VecKind, SemifiniteFunction<VecKind, T>>
impl<T> IndexedCoproduct<VecKind, SemifiniteFunction<VecKind, T>>
Trait Implementations§
Source§impl<K: ArrayKind, F> HasLen<K> for IndexedCoproduct<K, F>
impl<K: ArrayKind, F> HasLen<K> for IndexedCoproduct<K, F>
Source§impl<K: ArrayKind> IntoIterator for IndexedCoproduct<K, FiniteFunction<K>>
impl<K: ArrayKind> IntoIterator for IndexedCoproduct<K, FiniteFunction<K>>
Source§impl<K: ArrayKind, T> IntoIterator for IndexedCoproduct<K, SemifiniteFunction<K, T>>
impl<K: ArrayKind, T> IntoIterator for IndexedCoproduct<K, SemifiniteFunction<K, T>>
Auto Trait Implementations§
impl<K, F> Freeze for IndexedCoproduct<K, F>
impl<K, F> RefUnwindSafe for IndexedCoproduct<K, F>
impl<K, F> Send for IndexedCoproduct<K, F>
impl<K, F> Sync for IndexedCoproduct<K, F>
impl<K, F> Unpin for IndexedCoproduct<K, F>
impl<K, F> UnwindSafe for IndexedCoproduct<K, F>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)