Ticket #10965: patch-Lcs.lhs

File patch-Lcs.lhs, 1.8 KB (added by jon.olsson@…, 18 years ago)

Patch 1 needed for GHC 6.6 build

Line 
1Tue Aug 15 19:41:27 EDT 2006  Esa Ilari Vuokko <ei@vuokko.info>
2  * Workaround for HasBounds that was removed in base-2.0 (GHC 6.6)
3diff -rN -u old-hsdarcs-2/Lcs.lhs new-hsdarcs-2/Lcs.lhs
4--- Lcs.lhs   2006-11-02 09:05:05.000000000 -0500
5+++ Lcs.lhs   2006-11-02 09:05:05.000000000 -0500
6@@ -358,7 +358,8 @@
7 -- | goto next unchanged line, return the given line if unchanged
8 nextUnchanged :: BSTArray s -> Int -> ST s Int
9 nextUnchanged c i = do
10-  if i == (aLen c) + 1 then return i
11+  len <- aLenM c
12+  if i == len + 1 then return i
13      else do b <- readArray c i
14              if b then nextUnchanged c (i+1)
15                 else return i
16@@ -367,7 +368,8 @@
17 --   behind the last line
18 skipOneUnChanged :: BSTArray s -> Int -> ST s Int
19 skipOneUnChanged c i = do
20-  if i == (aLen c) + 1 then return i
21+  len <- aLenM c
22+  if i == len + 1 then return i
23      else do b <- readArray c i
24              if not b then return (i+1)
25                 else skipOneUnChanged c (i+1)
26@@ -381,8 +383,9 @@
27 
28 -- | goto next changed line, return the given line if changed
29 nextChanged :: BSTArray s -> Int -> ST s (Maybe Int)
30-nextChanged c i =
31-  if i <= aLen c
32+nextChanged c i = do
33+  len <- aLenM c
34+  if i <= len
35     then do b <- readArray c i
36             if not b then nextChanged c (i+1)
37                else return $ Just i
38@@ -430,8 +433,17 @@
39 initP :: [PackedString] -> PArray
40 initP a = listArray (0, length a) (nilPS:a)
41 
42+#if __GLASGOW_HASKELL__ > 604
43+aLen :: (IArray a e) => a Int e -> Int
44+aLen a = snd $ bounds a
45+aLenM :: (MArray a e m) => a Int e -> m Int
46+aLenM a = getBounds a >>= return . snd
47+#else
48 aLen :: HasBounds a => a Int e -> Int
49 aLen a = snd $ bounds a
50+aLenM :: (HasBounds a, Monad m) => a Int e -> m Int
51+aLenM = return . snd . bounds
52+#endif
53 \end{code}
54 
55 \begin{code}