-- | Bounds check, enabled when `debugCritical` = `True`.
--
--   This version is used to check operations that could corrupt the heap.
-- 
--   The first integer is the length of the array, and the second
--   is the index. The second must be greater or equal to '0' and less than
--   the first integer. If the not then `error` with the `String`.
--
checkCritical :: String -> Int -> Int -> a -> a
checkCritical loc n i v 
  | debugCritical 
  = if i >= 0 && i < n
        then v 
        else errorOfBounds loc n i

  | otherwise     = v
checkCritical :: String -> Int -> Int -> a -> a
checkCritical loc n i v 
  | debugCritical 
  = if i >= 0 && i < n
        then v 
        else errorOfBounds loc n i

  | otherwise     = v
checkCritical loc n i v 
  | debugCritical 
  = if i >= 0 && i < n
        then v 
        else errorOfBounds loc n i

  | otherwise     = v