Skip to content

Commit

Permalink
Generalize ToJSONFilter instance.
Browse files Browse the repository at this point in the history
Previously a pure function `a -> a` could only be promoted to
a filter in IO. Now we allow it to work with any instance of
MonadIO.  (This adds to #105.)
  • Loading branch information
jgm committed Aug 5, 2023
1 parent 9a7e845 commit 01b2b86
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Text/Pandoc/JSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ import System.Environment (getArgs)
class ToJSONFilter m a where
toJSONFilter :: a -> m ()

instance (Walkable a Pandoc) => ToJSONFilter IO (a -> a) where
toJSONFilter f = BL.getContents >>=
instance (Walkable a Pandoc, MonadIO m) => ToJSONFilter m (a -> a) where
toJSONFilter f = liftIO $ BL.getContents >>=
BL.putStr . encode . (walk f :: Pandoc -> Pandoc) . either error id .
eitherDecode'

Expand Down

0 comments on commit 01b2b86

Please sign in to comment.