
Can you post an example of your code? mapM and map are actually for pretty distinct purposes. If you find yourself wanting to map over a pure list in monadic code, you should really look at applicative style, e.g.: import Control.Applicative data Struct = .... deriving (Read) readStructs :: IO [Struct] readStructs = map read . lines <$> getContents It lets you apply a pure function (or a composition of pure functions) to a monadic value. Note that the above is exactly equivalent to: readStructs = do contents <- getContents return . map read . lines $ contents On Monday Jul 26, 2010, at 9:13 AM, Kevin Jardine wrote:
On Jul 26, 3:00 pm, Vo Minh Thu
wrote: Also, just like with IO, maybe restructuring the code to separate monadic code would help.
The specific monad I am dealing with carries state around inside it.
I could revert to a pure system in many cases by simply passing the state as a parameter but then that defeats the point of the monad and clutters up my function calls.
Also, in other cases, I am using a module that defines its own monads and have no choice but to use them.
I think I would prefer a style of programming where monads are equal citizens to pure function calls. There are various hints that such a style of programming is possible but as I say, I have not found any clear tutorials on it. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe