DistinctListModule
Operations over lists known to hold no duplicates.
Summary
| Name | Signature | Synopsis |
|---|---|---|
| Union cases | ||
| ToList | this.ToList | Returns the refined value as a standard list. |
| Operations | ||
| refinement | DistinctList.refinement () | No description available. |
| toList | DistinctList.toList input | Returns the refined value as a standard list. |
| create | DistinctList.create values | Admits a list, failing when it holds duplicates. |
| ofSeq | DistinctList.ofSeq values | Removes duplicates rather than rejecting them, preserving first-seen order. |
| empty | DistinctList.empty | The list with no items. |
| length | DistinctList.length input | Returns the number of items as a plain int. |
| contains | DistinctList.contains item input | Returns whether the item is present. |
| toMapBy | DistinctList.toMapBy projection input | Builds a map keyed by a projection of each item, failing when the projection sends two items to the same key. |
| toMap | DistinctList.toMap input | Builds a map from a distinct list of pairs, failing when two pairs share a key. |
| toSet | DistinctList.toSet input | Builds a set. |
| add | DistinctList.add item input | Adds an item, ignoring it when already present. |
| remove | DistinctList.remove item input | Removes an item. |
| union | DistinctList.union first second | Returns the items of either list, without duplicates. |
| intersect | DistinctList.intersect first second | Returns the items present in both lists. |
| difference | DistinctList.difference first second | Returns the items of the first list absent from the second. |
| filter | DistinctList.filter predicate input | Keeps the matching items. |
| map | DistinctList.map mapping input | Applies a mapping and removes any duplicates it introduces, since a mapping need not be injective. |
| choose | DistinctList.choose chooser input | Keeps the chosen items, removing any duplicates the chooser introduces. |
| sort | DistinctList.sort input | Reorders the items. |
| sortBy | DistinctList.sortBy projection input | Reorders the items by a projected key. |
| rev | DistinctList.rev input | Reverses the order of the items. |
| truncate | DistinctList.truncate count input | Keeps at most the first count items. |
| isEmpty | DistinctList.isEmpty input | Returns whether the list has no items. |
| tryHead | DistinctList.tryHead input | Returns the first item, if any. |
| exists | DistinctList.exists predicate input | Returns whether any item satisfies the predicate. |
| forall | DistinctList.forall predicate input | Returns whether every item satisfies the predicate. |
| tryFind | DistinctList.tryFind predicate input | Returns the first matching item, if any. |
| tryPick | DistinctList.tryPick chooser input | Returns the first item the chooser accepts, if any. |
| iter | DistinctList.iter action input | Applies an action to every item. |
| fold | DistinctList.fold folder state input | Folds over the items from an explicit seed. |
| sum | DistinctList.sum input | Adds every item, matching List.sum. |
| sumBy | DistinctList.sumBy projection input | Adds a projection of every item, matching List.sumBy. |
Union cases
Operations
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
Builds a map keyed by a projection of each item, failing when the projection sends
two items to the same key. Distinct items do not imply distinct projections.
Parameters
| Name | Type | Description |
|---|---|---|
| projection | 'value -> 'a | |
| input | DistinctList<'value> |
Returns
Result<Map<'a, 'value>, Violation>
kind:member
kind:member
Builds a set. Total and lossless — this is the operation that justifies the type,
because distinct items always produce a set of the same size, while
Set.ofList on an ordinary list silently collapses duplicates.
Parameters
| Name | Type | Description |
|---|---|---|
| input | DistinctList<'value> |
Returns
Set<'value>
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member