projects
/
haskell-directory.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6ff8c23
)
IntMap lookup now returns monad instead of Maybe.
author
jeanphilippe.bernardy@gmail.com
<unknown>
Sat, 11 Mar 2006 22:45:02 +0000
(22:45 +0000)
committer
jeanphilippe.bernardy@gmail.com
<unknown>
Sat, 11 Mar 2006 22:45:02 +0000
(22:45 +0000)
Data/IntMap.hs
patch
|
blob
|
history
diff --git
a/Data/IntMap.hs
b/Data/IntMap.hs
index
decce64
..
ca9e4e0
100644
(file)
--- 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