Haskell maps returning a monad

Posted by sabauma on Stack Overflow See other posts from Stack Overflow or by sabauma
Published on 2010-06-13T01:44:58Z Indexed on 2010/06/13 1:52 UTC
Read the original article Hit count: 252

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about haskell

Related posts about map