-- | replaces every matching transaction in the given journal counts
-- the number of changed transactions
changeTransaction
  :: [(Transaction, Transaction)]
  -> Journal
  -> (Journal, Integer)
changeTransaction ts = countUpdates (jTrans . traverse) h
  where
    h t1 = asum $ fmap g ts
      where g (t2, tNew) = guard (t1 == t2) *> Just tNew
  
-- | Update a traversal and count the number of updates
changeTransaction
  :: [(Transaction, Transaction)]
  -> Journal
  -> (Journal, Integer)
changeTransaction ts = countUpdates (jTrans . traverse) h
  where
    h t1 = asum $ fmap g ts
      where g (t2, tNew) = guard (t1 == t2) *> Just tNew
  
-- | Update a traversal and count the number of updates
changeTransaction ts = countUpdates (jTrans . traverse) h
  where
    h t1 = asum $ fmap g ts
      where g (t2, tNew) = guard (t1 == t2) *> Just tNew
  
-- | Update a traversal and count the number of updates