[Haskell-cafe] foreach

Michael Shulman viritrilbia at gmail.com
Wed Sep 13 16:44:37 EDT 2006


On 9/13/06, Henning Thielemann <lemming at henning-thielemann.de> wrote:
> If you want more sugar, what about the list monad?
>
> main = do
>          args <- getArgs
>          sequence_ $
>            do arg <- args
>               n <- [1..3]
>               return (putStrLn $ show n ++ ") " ++ arg)

Or, what about using ListT to combine it with IO, eliminating the need for
two separate `do' blocks?

main = (>> return ()) $ runListT $ do
         arg <- ListT getArgs
         n <- ListT $ return [1..3]
         liftIO $ putStrLn ((show n) ++ ") " ++ arg)

Mike


More information about the Haskell-Cafe mailing list