[Haskell-cafe] Improvement suggestions

2012-08-15 Thread José Lopes
Hello everyone, I am quite new to monadic code so I would like to ask for improvement suggestions on the last line of the code below. I know I could do something like do strs - mapM ...; intercalate ... etc, but I would like to avoid the use of -. Thank you, José data XmlState = XmlState

Re: [Haskell-cafe] Improvement suggestions

2012-08-15 Thread Twan van Laarhoven
On 15/08/12 17:01, José Lopes wrote: someFn docs = return concat `ap` (sequence $ intersperse (return \n) (map loop docs)) First of all, return x `ap` y = x `fmap` y or x $ y. fmap (or its infix synonym ($)) is the answer here, you could write: someFn docs = concat . intersperse \n $

Re: [Haskell-cafe] Improvement suggestions

2012-08-15 Thread Clark Gaebel
Try: concat . intersperse \n $ (sequence $ map loop docs) On Wed, Aug 15, 2012 at 11:01 AM, José Lopes jose.lo...@ist.utl.pt wrote: Hello everyone, I am quite new to monadic code so I would like to ask for improvement suggestions on the last line of the code below. I know I could do

Re: [Haskell-cafe] Improvement suggestions

2012-08-15 Thread José Lopes
Thank you. On 15-08-2012 23:09, Twan van Laarhoven wrote: On 15/08/12 17:01, José Lopes wrote: someFn docs = return concat `ap` (sequence $ intersperse (return \n) (map loop docs)) First of all, return x `ap` y = x `fmap` y or x $ y. fmap (or its infix synonym ($)) is the answer here,