git.iko.soy/typeable/pandoc
on master help sign in
Add a note on how `mapD` works.
06488c9Jesse Rosenthal
src/Text/Pandoc/Readers/Docx/Parse.hs+3
@@ -100,6 +100,9 @@ maybeToD Nothing = throwError DocxError
100concatMapM :: (Monad m) => (a -> m [b]) -> [a] -> m [b]
100concatMapM :: (Monad m) => (a -> m [b]) -> [a] -> m [b]
101concatMapM f xs = liftM concat (mapM f xs)
101concatMapM f xs = liftM concat (mapM f xs)
102
102
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.
103mapD :: (a -> D b) -> [a] -> D [b]
106mapD :: (a -> D b) -> [a] -> D [b]
104mapD f xs =
107mapD f xs =
105 let handler x = (f x >>= (\y-> return [y])) `catchError` (\_ -> return [])
108 let handler x = (f x >>= (\y-> return [y])) `catchError` (\_ -> return [])