Hi,

Am Freitag, den 23.01.2009, 21:50 +0100 schrieb Henning Thielemann:
>   However our recent Monoid discussion made me think about mapM_, 
> sequence_, and friends. I think they could be useful for many monads if 
> they would have the type:
>   mapM_ :: (Monoid b) => (a -> m b) -> [a] -> m b
>    I expect that the Monoid instance of () would yield the same efficiency 
> as todays mapM_

will it? This is based on a naive, not well-founded understanding of
haskell evaluation, but looking at
> instance Monoid () where
>       mempty        = ()
>       _ `mappend` _ = ()
>       mconcat _     = ()
I’d assume that evaluating
> mapM_ (putStrLn) lotsOfLargeStrings
with your proposed mapM_ will leave a thunk equivalent to
> () `mappend` () `mappend` () `mappend`...
in memory until the mapM_ has completely finished, where each () is
actually an unevalutated thunk that still has a reference to one of the
elements in the lotsOfLargeStrings list.

Greetings,
Joachim

-- 
Joachim "nomeata" Breitner
  mail: [email protected] | ICQ# 74513189 | GPG-Key: 4743206C
  JID: [email protected] | http://www.joachim-breitner.de/
  Debian Developer: [email protected]

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to