Re: [Haskell-cafe] Re: Composing monads

2007-11-23 Thread Luke Palmer
On Nov 23, 2007 6:24 PM, Jules Bean [EMAIL PROTECTED] wrote: ...i.e. I wouldn't be afraid of a lambda in a case like that. IME it's moderately common to have to do: mapM_ (\a - some stuff something_with a some stuff) ll This has terrible endweight. In this imperativesque case, I'd write:

Re: [Haskell-cafe] Re: Composing monads

2007-11-23 Thread Thomas Schilling
On Fri, 2007-11-23 at 23:01 +0100, Roberto Zunino wrote: Maurí­cio wrote: main = mapM_ ((putStrLn ) * putStrLn) $ map show [1,2,3] Using only standard combinators: main = mapM_ ((putStrLn ) . putStrLn) $ map show [1,2,3] == mapM_ ((putStrLn ) . putStrLn . show) [1,2,3]

Re: [Haskell-cafe] Re: Composing monads

2007-11-23 Thread Roberto Zunino
Maurí­cio wrote: main = mapM_ ((putStrLn ) * putStrLn) $ map show [1,2,3] Using only standard combinators: main = mapM_ ((putStrLn ) . putStrLn) $ map show [1,2,3] Zun. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Re: Composing monads

2007-11-23 Thread Jules Bean
module Main (Main.main) where import Control.Monad import System.IO (*) :: Monad m = m () - (a - m ()) - (a - m ()) (*) f f' = \a - do{ f; f' a; } main :: IO () main = mapM_ ((putStrLn ) * putStrLn) $ map show [1,2,3] There is nothing wrong with that, but I would normally write:

[Haskell-cafe] Re: Composing monads

2007-11-23 Thread Maurí­cio
Hi, If I have two computations a-IO b and b-IO c, can I join them to get an a-IO c computation? I imagine something like a liftM dot operator. This is called Kleisli composition, by the way; it's defined as (=) in Control.Monad. jcc Even if you didn't know about (=)(...):

[Haskell-cafe] Re: Composing monads

2007-11-23 Thread Hitesh
main :: IO () main = mapM_ ((putStrLn ) * putStrLn) $ map show [1,2,3] A couple other ways to do this code. Without monad combinators main = mapM_ putStrLn . (:) . intersperse . map show $ [1..3] With your combinator, but collapsing it so we don't map over the collection