[Haskell-beginners] Mapping inside State
martin.drautzburg at web.de
Tue Apr 1 04:15:58 UTC 2014
Am 03/31/2014 10:42 PM, schrieb Chaddaï Fouché:
> Le 31 mars 2014 18:07, "martin" <martin.drautzburg at web.de <mailto:martin.drautzburg at web.de>> a écrit :
>> Hello all,
>> I found myselft writing this ugly piece of code
>> silenceAll :: TI -> State (M.Map CH StringState,[DtzEvent]) TI
>> silenceAll t =
>> because I couldn't figure out how to map (silence t) over [0..6]. What is the standard way of doing this
> As said, mapM_ is the standard way to do that .
> How could you have found this for yourself ? The recommended way would be to use hoogle to search for the type signature
> you wish :
> (Monad m) => (a -> m b) -> [a] -> m ()
> mapM_ would be among the first results.
Thanks Ozgur and Chaddai, this works. Two more questions:
(1) I had tried mapM, but this didn't work. I am having trouble to understand why the return type is m() and not m [a]
(2) Hoogle is http://www.haskell.org/hoogle, right? I mean, it is a web thing, not something I use from the commandline?
More information about the Beginners