[Haskell-cafe] Improvement suggestions

Clark Gaebel cgaebel at uwaterloo.ca
Wed Aug 15 17:09:31 CEST 2012


Try:

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,
> José
>
> 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
> http://www.haskell.org/**mailman/listinfo/haskell-cafe<http://www.haskell.org/mailman/listinfo/haskell-cafe>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120815/ced35cbd/attachment.htm>


More information about the Haskell-Cafe mailing list