DistinctListModule
PackageReified.Refinements
Operations over lists known to hold no duplicates.
Summary
| Name | Signature | Synopsis |
|---|---|---|
| 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. |
Parameters
| Name | Type | Description |
|---|---|---|
| unit |
Returns
Refinement<'value list, DistinctList<'value>>
Returns the refined value as a standard list.
Parameters
| Name | Type | Description |
|---|---|---|
| input | DistinctList<'value> |
Returns
'value list
Admits a list, failing when it holds duplicates.
Parameters
| Name | Type | Description |
|---|---|---|
| values | 'a seq |
Returns
Result<DistinctList<'a>, Violation>
Removes duplicates rather than rejecting them, preserving first-seen order. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| values | 'a seq |
Returns
DistinctList<'a>
Returns the number of items as a plain
int.Parameters
| Name | Type | Description |
|---|---|---|
| input | DistinctList<'value> |
Returns
int
Returns whether the item is present.
Parameters
| Name | Type | Description |
|---|---|---|
| item | 'value | |
| input | DistinctList<'value> |
Returns
bool
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>
Builds a map from a distinct list of pairs, failing when two pairs share a key.
Parameters
| Name | Type | Description |
|---|---|---|
| input | DistinctList<'key * 'value> |
Returns
Result<Map<'key, 'value>, Violation>
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>
Adds an item, ignoring it when already present. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| item | 'value | |
| input | DistinctList<'value> |
Returns
DistinctList<'value>
Removes an item. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| item | 'value | |
| input | DistinctList<'value> |
Returns
DistinctList<'value>
Returns the items of either list, without duplicates. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| first | DistinctList<'value> | |
| second | DistinctList<'value> |
Returns
DistinctList<'value>
Returns the items present in both lists. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| first | DistinctList<'value> | |
| second | DistinctList<'value> |
Returns
DistinctList<'value>
Returns the items of the first list absent from the second. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| first | DistinctList<'value> | |
| second | DistinctList<'value> |
Returns
DistinctList<'value>
Keeps the matching items. Total — filtering cannot introduce duplicates.
Parameters
| Name | Type | Description |
|---|---|---|
| predicate | 'value -> bool | |
| input | DistinctList<'value> |
Returns
DistinctList<'value>
Applies a mapping and removes any duplicates it introduces, since a mapping need
not be injective. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| mapping | 'value -> 'a | |
| input | DistinctList<'value> |
Returns
DistinctList<'a>
Keeps the chosen items, removing any duplicates the chooser introduces. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| chooser | 'value -> 'a option | |
| input | DistinctList<'value> |
Returns
DistinctList<'a>
Reorders the items. Total — reordering cannot introduce duplicates.
Parameters
| Name | Type | Description |
|---|---|---|
| input | DistinctList<'value> |
Returns
DistinctList<'value>
Reorders the items by a projected key. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| projection | 'value -> 'a | |
| input | DistinctList<'value> |
Returns
DistinctList<'value>
Reverses the order of the items. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| input | DistinctList<'value> |
Returns
DistinctList<'value>
Keeps at most the first
count items. Total.Parameters
| Name | Type | Description |
|---|---|---|
| count | int | |
| input | DistinctList<'value> |
Returns
DistinctList<'value>
Returns whether the list has no items.
Parameters
| Name | Type | Description |
|---|---|---|
| input | DistinctList<'value> |
Returns
bool
Returns the first item, if any. Distinctness says nothing about emptiness.
Parameters
| Name | Type | Description |
|---|---|---|
| input | DistinctList<'value> |
Returns
'value option
Returns whether any item satisfies the predicate.
Parameters
| Name | Type | Description |
|---|---|---|
| predicate | 'value -> bool | |
| input | DistinctList<'value> |
Returns
bool
Returns whether every item satisfies the predicate.
Parameters
| Name | Type | Description |
|---|---|---|
| predicate | 'value -> bool | |
| input | DistinctList<'value> |
Returns
bool
Returns the first matching item, if any.
Parameters
| Name | Type | Description |
|---|---|---|
| predicate | 'value -> bool | |
| input | DistinctList<'value> |
Returns
'value option
Returns the first item the chooser accepts, if any.
Parameters
| Name | Type | Description |
|---|---|---|
| chooser | 'value -> 'a option | |
| input | DistinctList<'value> |
Returns
'a option
Applies an action to every item.
Parameters
| Name | Type | Description |
|---|---|---|
| action | 'value -> unit | |
| input | DistinctList<'value> |
Returns
unit
Folds over the items from an explicit seed.
Parameters
| Name | Type | Description |
|---|---|---|
| folder | 'a -> 'value -> 'a | |
| state | 'a | |
| input | DistinctList<'value> |
Returns
'a
Adds every item, matching
List.sum.Parameters
| Name | Type | Description |
|---|---|---|
| input | DistinctList<^value> |
Returns
^value