From badc7e1d40ce3afcd225de4f80452056935ca63a Mon Sep 17 00:00:00 2001 From: "jeanphilippe.bernardy@gmail.com" Date: Sat, 11 Mar 2006 22:45:02 +0000 Subject: [PATCH] IntMap lookup now returns monad instead of Maybe. --- Data/IntMap.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Data/IntMap.hs b/Data/IntMap.hs index decce64..ca9e4e0 100644 --- a/Data/IntMap.hs +++ b/Data/IntMap.hs @@ -269,8 +269,13 @@ notMember :: Key -> IntMap a -> Bool notMember k m = not $ member k m -- | /O(min(n,W))/. Lookup the value at a key in the map. -lookup :: Key -> IntMap a -> Maybe a -lookup k t +lookup :: (Monad m) => Key -> IntMap a -> m a +lookup k t = case lookup' k t of + Just x -> return x + Nothing -> fail "Data.IntMap.lookup: Key not found" + +lookup' :: Key -> IntMap a -> Maybe a +lookup' k t = let nk = natFromInt k in seq nk (lookupN nk t) lookupN :: Nat -> IntMap a -> Maybe a -- 1.7.10.4