Subject: Re: [boost] [MPL] new run-time algorithm: for_all
From: Larry Evans (cppljevans_at_[hidden])
Date: 2008-11-24 12:51:13


On 11/24/08 10:54, Larry Evans wrote:
> On 11/24/08 09:46, George van Venrooij wrote:
[snip]
> George, earlier this year, there was yet another person who had
> a proposed solution:
>
> http://thread.gmane.org/gmane.comp.lib.boost.devel/171761
>
> The OP in that thread benchmarked the solution:
>
> http://thread.gmane.org/gmane.comp.lib.boost.devel/171761/focus=172030
>
> I'd guess that before anything is adopted when there are several
> alternatives, the pros/cons and a benchmark comparing the alternatives
> would be desirable.
>

apfelmus' recent post to haskell.cafe ng provided a monadic version:

   sequence :: Monad m => [m a] -> m [a]
   {-# INLINE sequence #-}
   sequence ms = foldr k (return []) ms
            where
              k m m' = do { x <- m; xs <- m'; return (x:xs) }

of the crossf solution posted earlier:

   http://news.gmane.org/gmane.comp.lang.haskell.cafe/cutoff=47985

which looks very similar to the moncow 2 sequence version:

      cross :: [a] -> [b] -> [(a,b)]
      cross ls1 ls2 = do x <- ls1
                         y <- ls2
                         return (x,y)

found here:

   http://www.muitovar.com/monad/moncow.xhtml#list

which was mentioned in my first reply.

This suggests, at least to me, that monads
could be useful in mpl. Anybody else think
that's worth exploring?