git.iko.soy/typeable/pandoc
on master help sign in
Add a note on how `mapD` works.
commit06488c95fa9cf29c1b735c86764968796690e948 authorJesse Rosenthal <jrosenthal@jhu.edu> dateWed 6 Aug 2014, 09:56 (12 years ago) parent3bc2ea4
1 file changed+3
src/Text/Pandoc/Readers/Docx/Parse.hs+3
src/Text/Pandoc/Readers/Docx/Parse.hs+3
@@ -100,6 +100,9 @@ maybeToD Nothing = throwError DocxError
100100concatMapM :: (Monad m) => (a -> m [b]) -> [a] -> m [b]
101101concatMapM f xs = liftM concat (mapM f xs)
102102
103+
104+-- This is similar to `mapMaybe`: it maps a function returning the D
105+-- monad over a list, and only keeps the non-erroring return values.
103106mapD :: (a -> D b) -> [a] -> D [b]
104107mapD f xs =
105108 let handler x = (f x >>= (\y-> return [y])) `catchError` (\_ -> return [])