-- | Slice check, enable when `debug` = `True`.
--
--   The vector must contain at least `sliceStart` + `sliceLen` elements.
-- 
checkSlice :: String -> Int -> Int -> Int -> a -> a
checkSlice loc vecLen sliceStart sliceLen v
  | debug        
  = if   (  sliceStart >= 0             && sliceStart            <= vecLen
         && sliceStart + sliceLen >= 0  && sliceStart + sliceLen <= vecLen )
        then v
        else errorBadSlice loc vecLen sliceStart sliceLen

  | otherwise    = v
checkSlice :: String -> Int -> Int -> Int -> a -> a
checkSlice loc vecLen sliceStart sliceLen v
  | debug        
  = if   (  sliceStart >= 0             && sliceStart            <= vecLen
         && sliceStart + sliceLen >= 0  && sliceStart + sliceLen <= vecLen )
        then v
        else errorBadSlice loc vecLen sliceStart sliceLen

  | otherwise    = v
checkSlice loc vecLen sliceStart sliceLen v
  | debug        
  = if   (  sliceStart >= 0             && sliceStart            <= vecLen
         && sliceStart + sliceLen >= 0  && sliceStart + sliceLen <= vecLen )
        then v
        else errorBadSlice loc vecLen sliceStart sliceLen

  | otherwise    = v