(x `div` y)*y + (x `mod` y) == xWARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.
atomicModifyIORef' ref (x -> (x+1, undefined))will increment the IORef and then throw an exception in the calling thread. This function imposes a memory barrier, preventing reordering; see Data.IORef#memmodel for details.