summaryrefslogtreecommitdiff
path: root/devel/darcs/patches/patch-ab
blob: 47c17832bcfbce22f7965e502288d98d70037739 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$NetBSD: patch-ab,v 1.1 2007/03/24 17:58:04 kristerw Exp $

Patch needed for GHC 6.6.

--- Lcs.lhs.orig	2006-06-16 20:59:28.000000000 +0200
+++ Lcs.lhs	2007-02-25 22:12:31.000000000 +0100
@@ -358,7 +358,8 @@
 -- | goto next unchanged line, return the given line if unchanged
 nextUnchanged :: BSTArray s -> Int -> ST s Int
 nextUnchanged c i = do
-  if i == (aLen c) + 1 then return i
+  len <- aLenM c
+  if i == len + 1 then return i
      else do b <- readArray c i
              if b then nextUnchanged c (i+1)
                 else return i
@@ -367,7 +368,8 @@
 --   behind the last line
 skipOneUnChanged :: BSTArray s -> Int -> ST s Int
 skipOneUnChanged c i = do
-  if i == (aLen c) + 1 then return i
+  len <- aLenM c
+  if i == len + 1 then return i
      else do b <- readArray c i
              if not b then return (i+1)
                 else skipOneUnChanged c (i+1)
@@ -381,8 +383,9 @@
 
 -- | goto next changed line, return the given line if changed
 nextChanged :: BSTArray s -> Int -> ST s (Maybe Int)
-nextChanged c i =
-  if i <= aLen c
+nextChanged c i = do
+  len <- aLenM c
+  if i <= len
     then do b <- readArray c i
             if not b then nextChanged c (i+1)
                else return $ Just i
@@ -430,8 +433,17 @@
 initP :: [PackedString] -> PArray
 initP a = listArray (0, length a) (nilPS:a)
 
+#if __GLASGOW_HASKELL__ > 604
+aLen :: (IArray a e) => a Int e -> Int
+aLen a = snd $ bounds a
+aLenM :: (MArray a e m) => a Int e -> m Int
+aLenM a = getBounds a >>= return . snd
+#else
 aLen :: HasBounds a => a Int e -> Int
 aLen a = snd $ bounds a
+aLenM :: (HasBounds a, Monad m) => a Int e -> m Int
+aLenM = return . snd . bounds
+#endif
 \end{code}
 
 \begin{code}