From 1e6ad7ab1d081f69cfb09eac24f2a47536080fff Mon Sep 17 00:00:00 2001 From: simonpj Date: Wed, 12 Oct 2005 10:57:40 +0000 Subject: [PATCH] [project @ 2005-10-12 10:57:40 by simonpj] Comments --- GHC/Arr.lhs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/GHC/Arr.lhs b/GHC/Arr.lhs index c5e945f..0b29db0 100644 --- a/GHC/Arr.lhs +++ b/GHC/Arr.lhs @@ -75,12 +75,16 @@ class (Ord a) => Ix a where unsafeRangeSize :: (a,a) -> Int -- Must specify one of index, unsafeIndex - index b i | inRange b i = unsafeIndex b i + index b i | inRange b i = unsafeIndex b i | otherwise = error "Error in array index" unsafeIndex b i = index b i rangeSize b@(_l,h) | inRange b h = unsafeIndex b h + 1 - | otherwise = 0 + | otherwise = 0 -- This case is only here to + -- check for an empty range + -- NB: replacing (inRange b h) by (l <= h) fails for + -- tuples. E.g. (1,2) <= (2,1) but the range is empty + unsafeRangeSize b@(_l,h) = unsafeIndex b h + 1 \end{code} -- 1.7.10.4