[Haskell-cafe] Improvement suggestions
cgaebel at uwaterloo.ca
Wed Aug 15 17:09:31 CEST 2012
concat . intersperse "\n" <$> (sequence $ map loop docs)
On Wed, Aug 15, 2012 at 11:01 AM, José Lopes <jose.lopes at 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 something like "do strs <- mapM ...; intercalate ..."
> etc, but I would like to avoid the use of "<-".
> Thank you,
> data XmlState = XmlState Int
> type XmlM a = State XmlState a
> loop :: Document -> XmlM String
> someFn :: [Document] -> XmlM String
> someFn docs =
> return concat `ap` (sequence $ intersperse (return "\n") (map loop
> docs)) <--- improve this line
> José António Branquinho de Oliveira Lopes
> 58612 - MEIC-A
> Instituto Superior Técnico (IST), Universidade Técnica de Lisboa (UTL)
> jose.lopes at ist.utl.pt
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe