From 06488c95fa9cf29c1b735c86764968796690e948 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Wed, 6 Aug 2014 09:56:33 -0400 Subject: Add a note on how `mapD` works. --- src/Text/Pandoc/Readers/Docx/Parse.hs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs index 5cfe50c5c..96210c31a 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse.hs @@ -100,6 +100,9 @@ maybeToD Nothing = throwError DocxError concatMapM :: (Monad m) => (a -> m [b]) -> [a] -> m [b] concatMapM f xs = liftM concat (mapM f xs) + +-- This is similar to `mapMaybe`: it maps a function returning the D +-- monad over a list, and only keeps the non-erroring return values. mapD :: (a -> D b) -> [a] -> D [b] mapD f xs = let handler x = (f x >>= (\y-> return [y])) `catchError` (\_ -> return []) -- cgit v1.2.3