New patches: [Fix bug 1985 David Benbennick **20071224012920] { hunk ./Data/IntSet.hs 547 --- | /O(min(n,W))/. Retrieves the maximal key of the set, and the set stripped from that element +-- | /O(min(n,W))/. Retrieves the maximal key of the set, and the set stripped of that element. hunk ./Data/IntSet.hs 550 -maxView t - = case t of - Bin p m l r | m < 0 -> let (result,t') = maxViewUnsigned l in return (result, bin p m t' r) - Bin p m l r -> let (result,t') = maxViewUnsigned r in return (result, bin p m l t') - Tip y -> return (y,Nil) - Nil -> fail "maxView: empty set has no maximal element" +maxView Nil = fail "maxView: empty set has no maximal element" +maxView t = return $ deleteFindMax t hunk ./Data/IntSet.hs 559 --- | /O(min(n,W))/. Retrieves the minimal key of the set, and the set stripped from that element +-- | /O(min(n,W))/. Retrieves the minimal key of the set, and the set stripped of that element. hunk ./Data/IntSet.hs 562 -minView t - = case t of - Bin p m l r | m < 0 -> let (result,t') = minViewUnsigned r in return (result, bin p m l t') - Bin p m l r -> let (result,t') = minViewUnsigned l in return (result, bin p m t' r) - Tip y -> return (y, Nil) - Nil -> fail "minView: empty set has no minimal element" +minView Nil = fail "minView: empty set has no minimal element" +minView t = return $ deleteFindMin t hunk ./Data/IntSet.hs 572 --- Duplicate the Identity monad here because base < mtl. -newtype Identity a = Identity { runIdentity :: a } -instance Monad Identity where - return a = Identity a - m >>= k = k (runIdentity m) - - hunk ./Data/IntSet.hs 576 -deleteFindMin = runIdentity . minView +deleteFindMin Nil = (error "deleteFindMin: cannot return the minimal element of an empty set", Nil) +deleteFindMin (Tip y) = (y, Nil) +deleteFindMin (Bin p m l r) + | m < 0 = let (result, t') = minViewUnsigned r in (result, bin p m l t') + | otherwise = let (result, t') = minViewUnsigned l in (result, bin p m t' r) hunk ./Data/IntSet.hs 586 -deleteFindMax = runIdentity . maxView +deleteFindMax Nil = (error "deleteFindMax: cannot return the maximal element of an empty set", Nil) +deleteFindMax (Tip y) = (y, Nil) +deleteFindMax (Bin p m l r) + | m < 0 = let (result, t') = maxViewUnsigned l in (result, bin p m t' r) + | otherwise = let (result, t') = maxViewUnsigned r in (result, bin p m l t') hunk ./Data/IntSet.hs 594 -findMin = fst . runIdentity . minView +findMin = fst . deleteFindMin hunk ./Data/IntSet.hs 598 -findMax = fst . runIdentity . maxView +findMax = fst . deleteFindMax hunk ./Data/IntSet.hs 602 -deleteMin = snd . runIdentity . minView +deleteMin = snd . deleteFindMin hunk ./Data/IntSet.hs 606 -deleteMax = snd . runIdentity . maxView +deleteMax = snd . deleteFindMax } Context: [Fix a link in haddock docs Ian Lynagh **20071126184450] [Fix some URLs Ian Lynagh **20071126214233] [Add tiny regression test David Benbennick **20071113045358] [Fix ticket 1762 David Benbennick **20071111201939] [Specify build-type: Simple Duncan Coutts **20071018125404] [Add a boring file Ian Lynagh **20070913204647] [TAG 2007-09-13 Ian Lynagh **20070913215901] Patch bundle hash: ad8baf94a3c4817286c5a499d8b8e658ad874cd8