Re[2]: [Haskell-cafe] foreach

2006-09-14 Thread Bulat Ziganshin
Hello Tim, Wednesday, September 13, 2006, 10:48:37 PM, you wrote: > I would like to add to this. The previous loop runs the code > once independantly for each item in the list. Sometimes you want > to carry state through the loop: all this can be easily implemented by programmer himself.

Re[2]: [Haskell-cafe] foreach

2006-09-13 Thread Bulat Ziganshin
Hello Michael, Thursday, September 14, 2006, 12:44:37 AM, you wrote: > Or, what about using ListT to combine it with IO, eliminating the need for > two separate `do' blocks? according to my experience, in most cases we need two do blocks just because outer one contains more code after inner one

Re: Re[2]: [Haskell-cafe] foreach

2006-09-13 Thread Jeremy Shaw
At Wed, 13 Sep 2006 15:24:39 +0400, Bulat Ziganshin wrote: > because REAL code is somewhat larger than examples. try to rewrite the > following: > > directory_blocks <- (`mapM` splitBy (opt_group_dir command) > files_to_archive) > ( \filesInOneDirectory -> do > datablocks <- (`ma

Re[2]: [Haskell-cafe] foreach

2006-09-13 Thread Bulat Ziganshin
Hello Udo, Wednesday, September 13, 2006, 12:53:38 PM, you wrote: >> main = do >>args <- getArgs >>flip mapM_ args $ \arg -> >> flip mapM_ [1..3] $ \n -> >>putStrLn $ show n ++ ") " ++ arg > Or even: > main = do > args <- getArgs > putStr $ unlines [ show n ++ ") "

Re[2]: [Haskell-cafe] foreach

2006-09-13 Thread Bulat Ziganshin
Hello Henning, Wednesday, September 13, 2006, 1:12:35 PM, you wrote: > Adding sugar or using Template Haskell for such a simple task is a bit > unreasonable. I think Tim should use mapM a little bit and then he will > probably need no longer a special syntax. i disagree. lack of good syntax make