Map.lookup in 6.4.1 (and 6.4.2)
Christian Maeder
maeder at tzi.de
Thu Aug 10 06:35:07 EDT 2006
Serge D. Mechveliani schrieb:
> Please, what is the matter with Map.lookup ?
Map.lookup results in any monad. At the ghci prompt that is the IO monad
(and not Maybe).
Prelude> :t Data.Map.lookup
Data.Map.lookup :: forall a (m :: * -> *) k.
(Ord k, Monad m) =>
k -> Data.Map.Map k a -> m a
Prelude> x <- Data.Map.lookup 'a' $ Data.Map.singleton 'a' 'b'
<interactive>:1:0: Warning: Defined but not used: `x'
Prelude> x
'b'
(N.B. this warning is confusing, but I've set -Wall)
Supply a type signature if you want a different result:
Prelude> Data.Map.lookup 'a' $ Data.Map.singleton 'a' 'b' :: Maybe Char
Just 'b'
HTH Christian
More information about the Glasgow-haskell-users
mailing list