From: jeanphilippe.bernardy@gmail.com Date: Sat, 11 Mar 2006 22:45:02 +0000 (+0000) Subject: IntMap lookup now returns monad instead of Maybe. X-Git-Tag: directory_2007-05-24~325 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=badc7e1d40ce3afcd225de4f80452056935ca63a;p=haskell-directory.git IntMap lookup now returns monad instead of Maybe. --- 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