aiken/collection/dict/strategy
This module contains strategies used to transform Dict. You can safely ignore this module if you aren’t using union_with nor insert_with.
Types
A callback to discard a value at a given key
Alias
DiscardValue<key, value> = fn() -> Pairs<key, value>A callback to keep a combined value at a given key
Alias
KeepValue<key, value> = fn(value) -> Pairs<key, value>A strategy for combining two values in a dictionnary that belong to the same key.
Alias
UnionStrategy<key, value> = fn(
    key,
    value,
    value,
    KeepValue<key, value>,
    DiscardValue<key, value>,
  ) ->
    Pairs<key, value>Functions
Union Strategies
      
  
  
  
      
        
        A strategy which always fail, enforcing the dict contains no duplicate.
fn(_, _, _, _, _) {
  fail @"unexpected duplicate key found in dict."
}
      
    
  
  
      
        
        Combine values by keeping the values present in the left-most dict.
fn(_key, left, _right, keep, _discard) { keep(left) }
      
    
  
  
      
        
        Combine values by keeping the values present in the right-most dict.
fn(_key, _left, right, keep, _discard) { keep(right) }
      
    
  
  
      
        
        Combine values by taking their sum.
fn(_key, left, right, keep, _discard) { keep(left + right) }
      
    
  
  
      
    
  
A strategy which always fail, enforcing the dict contains no duplicate.
fn(_, _, _, _, _) {
  fail @"unexpected duplicate key found in dict."
}
Combine values by keeping the values present in the left-most dict.
fn(_key, left, _right, keep, _discard) { keep(left) }
Combine values by keeping the values present in the right-most dict.
fn(_key, _left, right, keep, _discard) { keep(right) }
Combine values by taking their sum.
fn(_key, left, right, keep, _discard) { keep(left + right) }