1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Flip the semigroup operator in storeInsert.

This commit is contained in:
Rob Rix 2018-03-07 12:00:04 -05:00
parent 57521b10f1
commit 48e1ae7003

View File

@ -31,7 +31,9 @@ storeLookupAll address = fmap toList . storeLookup address
-- | Append a value onto the cell for a given address, inserting a new cell if none existed.
storeInsert :: (Ord l, Reducer a (Cell l a)) => Address l a -> a -> Store l a -> Store l a
storeInsert (Address address) value = Store . Map.insertWith (<>) address (unit value) . unStore
storeInsert (Address address) value
-- Per the docs, 'Map.insertWith' applies its function operand to the new value first, followed by the old value. For 'Latest' this will result in us always keeping the oldest value instead of the latest one, which is exactly opposite to the desired semantics.
= Store . Map.insertWith (flip (<>)) address (unit value) . unStore
-- | The number of addresses extant in a 'Store'.
storeSize :: Store l a -> Int