Hello, I needed to compose monadic functions, since I couldn't find anything in Control.Monad so I defined my own. I first came up with a left associative version:
compLM [f1,..., fn] a = (f1 a >>= f2) >>= ... >>= fn > compLM :: Monad m => [a->m a] -> (a->m a) > compLM mfs a = foldl (>>=) (return a) mfs Later a right associative version, which I believe to be more efficient, particularly when some computation returns fail: compRM [f1,..., fn] a = \x->f1 x >>= (\x->f2 x >>= ... >>= \x->fn x) a > compRM :: Monad m => [a->m a] -> (a->m a) > compRM = foldr (\f g-> (\x ->f x >>= g)) return This higher order function seems quite useful to me and not trivial, so I expected it to be available. When this happens I wonder if I'm missing something. Am I complicating things? Is it actually available (or some other that does the trick) ? Or is it just me who finds this usefull enough to be in the libs? J.A. _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe