Skip to content
  • Duncan Coutts's avatar
    Introduce (but not yet use) monoids MapLast and MapMappend · 916a502a
    Duncan Coutts authored
    These are newtype wrappers with different Monoid instances. This is for
    following our more recent approach to the Monoid instances of our config
    types where rather than having custom mappen methods, we derive generic
    Monoid/Semigroup instances and rely on using special types like NubList
    for individual fields that need different mappend behaviour.
    
    The Map type has mappend behaviour that is not usually what we want for
    our configuration types. The normal Map mappend prefers the first
    argument over the second when keys overlap between the two maps. We
    normally want later things to either override or to extend, like our
    normal Flag (like Last) monoid or list monoid. So MapLast is a Map with
    Flag/Last-like behaviour, ie flip Map.union, while MapMappend is a Map
    that merges values when keys overlap, ie Map.unionWith (<>). The latter
    helps when the Map values are lists or further records.
    916a502a