
10 Aug
2006
10 Aug
'06
6:35 a.m.
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