# Ticket #1985: patch.txt

File patch.txt, 3.3 KB (added by dbenbenn, 10 years ago)
Line
1
2New patches:
3
4[Fix bug 1985
5David Benbennick <dbenbenn@gmail.com>**20071224012920] {
6hunk ./Data/IntSet.hs 547
7--- | /O(min(n,W))/. Retrieves the maximal key of the set, and the set stripped from that element
8+-- | /O(min(n,W))/. Retrieves the maximal key of the set, and the set stripped of that element.
9hunk ./Data/IntSet.hs 550
10-maxView t
11-    = case t of
12-        Bin p m l r | m < 0 -> let (result,t') = maxViewUnsigned l in return (result, bin p m t' r)
13-        Bin p m l r         -> let (result,t') = maxViewUnsigned r in return (result, bin p m l t')
14-        Tip y -> return (y,Nil)
15-        Nil -> fail "maxView: empty set has no maximal element"
16+maxView Nil = fail "maxView: empty set has no maximal element"
17+maxView t = return \$ deleteFindMax t
18hunk ./Data/IntSet.hs 559
19--- | /O(min(n,W))/. Retrieves the minimal key of the set, and the set stripped from that element
20+-- | /O(min(n,W))/. Retrieves the minimal key of the set, and the set stripped of that element.
21hunk ./Data/IntSet.hs 562
22-minView t
23-    = case t of
24-        Bin p m l r | m < 0 -> let (result,t') = minViewUnsigned r in return (result, bin p m l t')
25-        Bin p m l r         -> let (result,t') = minViewUnsigned l in return (result, bin p m t' r)
26-        Tip y -> return (y, Nil)
27-        Nil -> fail "minView: empty set has no minimal element"
28+minView Nil = fail "minView: empty set has no minimal element"
29+minView t = return \$ deleteFindMin t
30hunk ./Data/IntSet.hs 572
31--- Duplicate the Identity monad here because base < mtl.
32-newtype Identity a = Identity { runIdentity :: a }
34-       return a = Identity a
35-       m >>= k  = k (runIdentity m)
36-
37-
38hunk ./Data/IntSet.hs 576
39-deleteFindMin = runIdentity . minView
40+deleteFindMin Nil = (error "deleteFindMin: cannot return the minimal element of an empty set", Nil)
41+deleteFindMin (Tip y) = (y, Nil)
42+deleteFindMin (Bin p m l r)
43+  | m < 0 = let (result, t') = minViewUnsigned r in (result, bin p m l t')
44+  | otherwise = let (result, t') = minViewUnsigned l in (result, bin p m t' r)
45hunk ./Data/IntSet.hs 586
46-deleteFindMax = runIdentity . maxView
47+deleteFindMax Nil = (error "deleteFindMax: cannot return the maximal element of an empty set", Nil)
48+deleteFindMax (Tip y) = (y, Nil)
49+deleteFindMax (Bin p m l r)
50+  | m < 0 = let (result, t') = maxViewUnsigned l in (result, bin p m t' r)
51+  | otherwise = let (result, t') = maxViewUnsigned r in (result, bin p m l t')
52hunk ./Data/IntSet.hs 594
53-findMin = fst . runIdentity . minView
54+findMin = fst . deleteFindMin
55hunk ./Data/IntSet.hs 598
56-findMax = fst . runIdentity . maxView
57+findMax = fst . deleteFindMax
58hunk ./Data/IntSet.hs 602
59-deleteMin = snd . runIdentity . minView
60+deleteMin = snd . deleteFindMin
61hunk ./Data/IntSet.hs 606
62-deleteMax = snd . runIdentity . maxView
63+deleteMax = snd . deleteFindMax
64}
65
66Context:
67
69Ian Lynagh <igloo@earth.li>**20071126184450]
70[Fix some URLs
71Ian Lynagh <igloo@earth.li>**20071126214233]