on master help sign in
producer branch of conduit
commita9358b65e2e1797528a43bd174a1988eed2039e3 authorMichael Snoyman <michael@snoyman.com> dateWed 13 Feb 2013, 10:43 (14 years ago) parentdee4776
1 file changed+6−21
Text/Libyaml.hs+6−21
Text/Libyaml.hs+6−21
@@ -467,7 +467,7 @@ instance Exception ToEventRawException
467467
468468decode :: MonadResource m => B.ByteString
469469#if MIN_VERSION_conduit(1, 0, 0)
470− -> MonadSource m Event
470+ -> Producer m Event
471471#else
472472 -> GSource m Event
473473#endif
@@ -496,7 +496,7 @@ decode bs =
496496
497497decodeFile :: MonadResource m => FilePath
498498#if MIN_VERSION_conduit(1, 0, 0)
499− -> MonadSource m Event
499+ -> Producer m Event
500500#else
501501 -> GSource m Event
502502#endif
@@ -532,22 +532,14 @@ decodeFile file =
532532
533533runParser :: MonadResource m => Parser
534534#if MIN_VERSION_conduit(1, 0, 0)
535− -> MonadSource m Event
535+ -> Producer m Event
536536#else
537537 -> GSource m Event
538538#endif
539539runParser parser = do
540−#if MIN_VERSION_conduit(1, 0, 0)
541− e <- liftStreamIO $ parserParseOne' parser
542−#else
543540 e <- liftIO $ parserParseOne' parser
544−#endif
545541 case e of
546−#if MIN_VERSION_conduit(1, 0, 0)
547− Left err -> liftStreamIO $ throwIO err
548−#else
549542 Left err -> liftIO $ throwIO err
550−#endif
551543 Right Nothing -> return ()
552544 Right (Just ev) -> yield ev >> runParser parser
553545
@@ -569,7 +561,7 @@ parserParseOne' parser = allocaBytes eventSize $ \er -> do
569561
570562encode :: MonadResource m
571563#if MIN_VERSION_conduit(1, 0, 0)
572− => MonadSink Event m ByteString
564+ => Consumer Event m ByteString
573565#else
574566 => GSink Event m ByteString
575567#endif
@@ -590,7 +582,7 @@ encode =
590582encodeFile :: MonadResource m
591583 => FilePath
592584#if MIN_VERSION_conduit(1, 0, 0)
593− -> MonadSink Event m ()
585+ -> Consumer Event m ()
594586#else
595587 -> GInfSink Event m
596588#endif
@@ -611,7 +603,7 @@ runEmitter :: MonadResource m
611603 => (Emitter -> IO a) -- ^ alloc
612604#if MIN_VERSION_conduit(1, 0, 0)
613605 -> (() -> a -> IO b) -- ^ close
614− -> MonadSink Event m b
606+ -> Consumer Event m b
615607#else
616608 -> (u -> a -> IO b) -- ^ close
617609 -> Pipe l Event o u m b
@@ -638,17 +630,10 @@ runEmitter allocI closeI =
638630 loop = awaitE >>= either close push
639631#endif
640632
641−#if MIN_VERSION_conduit(1, 0, 0)
642− push e = do
643− _ <- liftStreamIO $ toEventRaw e $ c_yaml_emitter_emit emitter
644− loop
645− close u = liftStreamIO $ closeI u a
646−#else
647633 push e = do
648634 _ <- liftIO $ toEventRaw e $ c_yaml_emitter_emit emitter
649635 loop
650636 close u = liftIO $ closeI u a
651−#endif
652637
653638-- | The pointer position
654639data YamlMark = YamlMark { yamlIndex :: Int, yamlLine :: Int, yamlColumn :: Int }