Haskell maps returning a monad
- by sabauma
The lookup function in Data.Map and Data.IntMap currently return values wrapped in Maybe with
the type signature
lookup :: Ord k => k -> Map k a -> Maybe a
It used to have the more general type of
lookup :: (Monad m, Ord k) => k -> Map k a -> m a
I realize the former likely reduces the need of extra type specification, but the latter would make it much more general and allow lookup to be used in list comprehensions. Is there any way to mimic this behavior with the newer version, or would I have to use an older version of the library?