aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2014-08-06 09:56:33 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2014-08-06 11:20:41 -0400
commit06488c95fa9cf29c1b735c86764968796690e948 (patch)
treee9492e9190748e8759ba784ecbab3f5ed244e6ff
parent3bc2ea4cf753997738f0247be854b04ca91456e3 (diff)
downloadpandoc-06488c95fa9cf29c1b735c86764968796690e948.tar.gz
Add a note on how `mapD` works.
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs3
1 files changed, 3 insertions, 0 deletions
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 [])