@@ -91,14 +91,15 @@ import Data.Scientific (fromFloatDigits)
92import Data.Attoparsec.Number
92import Data.Attoparsec.Number
94+import Control.Monad.Trans.Resource (ResourceT, runResourceT)
95encode :: ToJSON a => a -> ByteString
96encode :: ToJSON a => a -> ByteString
96encode obj = unsafePerformIO $
97encode obj = unsafePerformIO $
97− C.runResourceT $ CL.sourceList (objToEvents $ toJSON obj)
98+ runResourceT $ CL.sourceList (objToEvents $ toJSON obj)
98 C.$$ Y.encode
99 C.$$ Y.encode
100encodeFile :: ToJSON a => FilePath -> a -> IO ()
101encodeFile :: ToJSON a => FilePath -> a -> IO ()
101−encodeFile fp obj = C.runResourceT
102+encodeFile fp obj = runResourceT
102 $ CL.sourceList (objToEvents $ toJSON obj)
103 $ CL.sourceList (objToEvents $ toJSON obj)
103 C.$$ Y.encodeFile fp
104 C.$$ Y.encodeFile fp
@@ -187,7 +188,7 @@ instance MonadTrans PErrorT where
187instance MonadIO m => MonadIO (PErrorT m) where
188instance MonadIO m => MonadIO (PErrorT m) where
188 liftIO = lift . liftIO
189 liftIO = lift . liftIO
190−type Parse = StateT (Map.Map String Value) (C.ResourceT IO)
191+type Parse = StateT (Map.Map String Value) (ResourceT IO)
192requireEvent :: Event -> C.Sink Event Parse ()
193requireEvent :: Event -> C.Sink Event Parse ()
193requireEvent e = do
194requireEvent e = do
@@ -320,7 +321,7 @@ decodeFileEither
320 => FilePath
321 => FilePath
321 -> IO (Either ParseException a)
322 -> IO (Either ParseException a)
322decodeFileEither fp = do
323decodeFileEither fp = do
323− x <- try $ C.runResourceT $ flip evalStateT Map.empty $ Y.decodeFile fp C.$$ parse
324+ x <- try $ runResourceT $ flip evalStateT Map.empty $ Y.decodeFile fp C.$$ parse
324 case x of
325 case x of
326 | Just pe <- fromException e -> return $ Left pe
327 | Just pe <- fromException e -> return $ Left pe
@@ -356,7 +357,7 @@ decodeHelper :: FromJSON a
356 => C.Source Parse Y.Event
357 => C.Source Parse Y.Event
357 -> IO (Either ParseException (Either String a))
358 -> IO (Either ParseException (Either String a))
358decodeHelper src = do
359decodeHelper src = do
359− x <- try $ C.runResourceT $ flip evalStateT Map.empty $ src C.$$ parse
360+ x <- try $ runResourceT $ flip evalStateT Map.empty $ src C.$$ parse
360 case x of
361 case x of
362 | Just pe <- fromException e -> return $ Left pe
363 | Just pe <- fromException e -> return $ Left pe