@@ -11,8 +11,7 @@ import qualified Data.ByteString.Char8 as B8
1111
1212import Test.HUnit hiding (Test, path)
1313
14−import qualified Data.Conduit as C
15−import qualified Control.Monad.Trans.Resource as C
14+import Data.Conduit (runConduitRes, (.|), ConduitM)
1615import qualified Data.Conduit.List as CL
1716
1817import Control.Monad
@@ -172,7 +171,7 @@ specialStrings =
172171 , "foo\nbar\nbaz\n"
173172 ]
174173
175−counter :: Monad m => (Y.Event -> Bool) -> C.Sink Y.Event m Int
174+counter :: Monad m => (Y.Event -> Bool) -> ConduitM Y.Event o m Int
176175counter pred' =
177176 CL.fold (\cnt e -> (if pred' e then 1 else 0) + cnt) 0
178177
@@ -181,7 +180,7 @@ caseHelper :: String
181180 -> Int
182181 -> Assertion
183182caseHelper yamlString pred' expRes = do
184− res <- C.runResourceT $ Y.decode (B8.pack yamlString) C.$$ counter pred'
183+ res <- runConduitRes $ Y.decode (B8.pack yamlString) .| counter pred'
185184 res @?= expRes
186185
187186caseCountScalarsWithAnchor :: Assertion
@@ -218,7 +217,7 @@ caseCountAliases =
218217
219218caseCountScalars :: Assertion
220219caseCountScalars = do
221− res <- C.runResourceT $ Y.decode yamlBS C.$$ CL.fold adder accum
220+ res <- runConduitRes $ Y.decode yamlBS .| CL.fold adder accum
222221 res @?= (7, 1, 2)
223222 where
224223 yamlString = "foo:\n baz: [bin1, bin2, bin3]\nbaz: bazval"
@@ -231,7 +230,7 @@ caseCountScalars = do
231230
232231caseLargestString :: Assertion
233232caseLargestString = do
234− res <- C.runResourceT $ Y.decodeFile filePath C.$$ CL.fold adder accum
233+ res <- runConduitRes $ Y.decodeFile filePath .| CL.fold adder accum
235234 res @?= (length expected, expected)
236235 where
237236 expected = "this one is just a little bit bigger than the others"
@@ -251,9 +250,9 @@ instance Eq MyEvent where
251250
252251caseEncodeDecode :: Assertion
253252caseEncodeDecode = do
254− eList <- C.runResourceT $ Y.decode yamlBS C.$$ CL.consume
255− bs <- C.runResourceT $ CL.sourceList eList C.$$ Y.encode
256− eList2 <- C.runResourceT $ Y.decode bs C.$$ CL.consume
253+ eList <- runConduitRes $ Y.decode yamlBS .| CL.consume
254+ bs <- runConduitRes $ CL.sourceList eList .| Y.encode
255+ eList2 <- runConduitRes $ Y.decode bs .| CL.consume
257256 map MyEvent eList @=? map MyEvent eList2
258257 where
259258 yamlString = "foo: bar\nbaz:\n - bin1\n - bin2\n"
@@ -261,17 +260,17 @@ caseEncodeDecode = do
261260
262261caseEncodeDecodeFile :: Assertion
263262caseEncodeDecodeFile = withFile "" $ \tmpPath -> do
264− eList <- C.runResourceT $ Y.decodeFile filePath C.$$ CL.consume
265− C.runResourceT $ CL.sourceList eList C.$$ Y.encodeFile tmpPath
266− eList2 <- C.runResourceT $ Y.decodeFile filePath C.$$ CL.consume
263+ eList <- runConduitRes $ Y.decodeFile filePath .| CL.consume
264+ runConduitRes $ CL.sourceList eList .| Y.encodeFile tmpPath
265+ eList2 <- runConduitRes $ Y.decodeFile filePath .| CL.consume
267266 map MyEvent eList @=? map MyEvent eList2
268267 where
269268 filePath = "test/largest-string.yaml"
270269
271270caseInterleave :: Assertion
272271caseInterleave = withFile "" $ \tmpPath -> withFile "" $ \tmpPath2 -> do
273− () <- C.runResourceT $ Y.decodeFile filePath C.$$ Y.encodeFile tmpPath
274− () <- C.runResourceT $ Y.decodeFile tmpPath C.$$ Y.encodeFile tmpPath2
272+ () <- runConduitRes $ Y.decodeFile filePath .| Y.encodeFile tmpPath
273+ () <- runConduitRes $ Y.decodeFile tmpPath .| Y.encodeFile tmpPath2
275274 f1 <- readFile tmpPath
276275 f2 <- readFile tmpPath2
277276 f1 @=? f2
@@ -280,7 +279,7 @@ caseInterleave = withFile "" $ \tmpPath -> withFile "" $ \tmpPath2 -> do
280279
281280caseDecodeInvalidDocument :: Assertion
282281caseDecodeInvalidDocument = do
283− x <- try $ C.runResourceT $ Y.decode yamlBS C.$$ CL.sinkNull
282+ x <- try $ runConduitRes $ Y.decode yamlBS .| CL.sinkNull
284283 case x of
285284 Left (_ :: SomeException) -> return ()
286285 Right y -> do