diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-01-24 11:50:35 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-01-24 11:50:35 -0800 |
commit | 8aa3d1cccc92250f4385260905142f04dd38b2ec (patch) | |
tree | cbc1b0fd56bca5a52c4dfbab075013e5c581034c /src/Text/Pandoc.hs | |
parent | de9f3f44203f088143a6fdc8cdeb6a7542c5cf88 (diff) |
Text.Pandoc: Added ToFilter instance for a -> [a] types.
Diffstat (limited to 'src/Text/Pandoc.hs')
-rw-r--r-- | src/Text/Pandoc.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index ba05589cd..0cd1af099 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -247,3 +247,13 @@ instance (Data a) => ToJsonFilter (a -> a) where instance (Data a) => ToJsonFilter (a -> IO a) where toJsonFilter f = getContents >>= (bottomUpM f :: Pandoc -> IO Pandoc) . decodeJSON >>= putStr . encodeJSON + +instance (Data a) => ToJsonFilter (a -> [a]) where + toJsonFilter f = getContents + >>= putStr . encodeJSON . (bottomUp (concatMap f) :: Pandoc -> Pandoc) . decodeJSON + +instance (Data a) => ToJsonFilter (a -> IO [a]) where + toJsonFilter f = getContents + >>= (bottomUpM (fmap concat . mapM f) :: Pandoc -> IO Pandoc) . decodeJSON + >>= putStr . encodeJSON + |