dicts
The dicts
module provides both functions and a Dict
class, a thin wrapper around a python dict
that simplifies chaining operations.
Dict[K, V]
from haskellian import Dict
Dict({ 'a': 1, 'b': 2, 'c': 3 }) \
.filter_k(lambda k: k != 'b') \
.evolve({ 'c': lambda x: 2*x }) \
.map(lambda k, v: f'{k}={v}')
# Dict({'a': 'a=1', 'c': 'c=6'})
Next up, promise