IntMap lookup now returns monad instead of Maybe.
authorjeanphilippe.bernardy@gmail.com <unknown>
Sat, 11 Mar 2006 22:45:02 +0000 (22:45 +0000)
committerjeanphilippe.bernardy@gmail.com <unknown>
Sat, 11 Mar 2006 22:45:02 +0000 (22:45 +0000)
Data/IntMap.hs

index decce64..ca9e4e0 100644 (file)
@@ -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