I don't think this is without point.

1
2
3
4
5
6
7
8
9
accounting :: Monad m => StateT Text m a -> StateT (Int, Text) m a
accounting action = do
  old <- uses _2 T.length
  v <- zoom _2 action
  new <- uses _2 T.length
  _1 += old - new
  return v

separate f = P . mapStateT maybeToList . accounting . StateT