om 1-index.

{- |
increment the value at index i(1-base) by amount w. O(log n)
But this use immutable Vector.
-}
inc :: Monoid a => Int -> a -> BIT a -> BIT a
inc i w b | 1 <= i && i <= n = b { vec = V.accum (<>) v . zip xs . repeat $ w }
          | otherwise = error $ "index must be between 1 to " ++ show n
  where (n, v) = (getN b, vec b)
        xs = takeWhile (<=n) . iterate (\x -> x + x .&. (-x)) $ i

{- |
increment the value at index i(1-base) by amount w. O(log n)
this use mutable Vector.
-}
inc' :: Monoid 
inc :: Monoid a => Int -> a -> BIT a -> BIT a
inc i w b | 1 <= i && i <= n = b { vec = V.accum (<>) v . zip xs . repeat $ w }
          | otherwise = error $ "index must be between 1 to " ++ show n
  where (n, v) = (getN b, vec b)
        xs = takeWhile (<=n) . iterate (\x -> x + x .&. (-x)) $ i

{- |
increment the value at index i(1-base) by amount w. O(log n)
this use mutable Vector.
-}
inc i w b | 1 <= i && i <= n = b { vec = V.accum (<>) v . zip xs . repeat $ w }
          | otherwise = error $ "index must be between 1 to " ++ show n
  where (n, v) = (getN b, vec b)
        xs = takeWhile (<=n) . iterate (\x -> x + x .&. (-x)) $ i

{- |
increment the value at index i(1-base) by amount w. O(log n)
this use mutable Vector.
-}