           | jB+1 < ny = goB 0 (jB+1) acc
           | otherwise = return acc
           where
+            applyTo i j acc = f acc x y . toValue =<< peekElemOff ptr (j*sx+i)
+              where x = iB*sx+i
+                    y = jB*sy+j
             stopx
               | mx /= 0 && iB==nx-1 = mx
               | otherwise           = sx

                    Nothing -> Value
                    Just nd ->
                      \v -> if toNodata v == nd then NoData else Value v
        applyTo i j acc = f acc . toValue =<< peekElemOff ptr (j*sx+i)
        goB !iB !jB !acc
          | iB < nx   = do
              throwIfError "could not read block" $

  , writeBand
  , writeBandBlock
  , fillBand

  , foldl'
  , foldlM'
  , ifoldl'
  , ifoldlM'

  -- Internal Util
  , throwIfError
