on master help sign in
Remove tautological CPP blocks regarding conduit versions

These changes should affect neither the interface nor the behaviour of this library. dee4776d27863b32d4a70c7f23d732426ccafb84 introduced compatibility with conduit 1.0, while retaining compatibility with pre-1.0 conduit. Because yaml has required conduit 1.0+ since 932a36abb40a591ec29df6cd741f720054bdfe7c, these version checks are no longer necessary. aa154a5c4b67a1d1952044d310cf5557d571b117 introduced compatibility with conduit 1.1, while retaining compatibility with pre-1.1 conduit. Because yaml has required conduit 1.1+ since fe4ef271af13ae86aef515b55a667e6255081896, these version checks are no longer necessary.

commit0f18162c7d52dd11899d22084bc2d0788afc3af5 authorStijn van Drongelen <rhymoid@gmail.com> dateThu 15 Jun 2017, 18:10 (9 years ago) parent23efce4
2 files changed+5−43
Data/Yaml/Parser.hs+1−6 Text/Libyaml.hs+4−37
Data/Yaml/Parser.hs+1−6
@@ -13,12 +13,7 @@ import Control.Monad.Trans.Resource (MonadThrow, monadThrow, runResourceT)
1313import Control.Monad.Trans.Writer.Strict (tell, WriterT)
1414import Data.ByteString (ByteString)
1515import Data.Conduit
16−#if MIN_VERSION_conduit(1,1,0)
1716import Data.Conduit.Lift (runWriterC)
18−#define runWriterSC runWriterC
19−#else
20−import Data.Conduit.Lift (runWriterSC)
21−#endif
2217import qualified Data.Map as Map
2318#if !MIN_VERSION_base(4,8,0)
2419import Data.Monoid (Monoid (..))
@@ -193,7 +188,7 @@ sinkValue =
193188 Just e -> monadThrow $ UnexpectedEvent e
194189
195190sinkRawDoc :: MonadThrow m => Consumer Event m RawDoc
196−sinkRawDoc = uncurry RawDoc <$> runWriterSC sinkValue
191+sinkRawDoc = uncurry RawDoc <$> runWriterC sinkValue
197192
198193readYamlFile :: FromYaml a => FilePath -> IO a
199194readYamlFile fp = runResourceT (decodeFile fp $$ sinkRawDoc) >>= parseRawDoc
Text/Libyaml.hs+4−37
@@ -479,12 +479,7 @@ newtype ToEventRawException = ToEventRawException CInt
479479 deriving (Show, Typeable)
480480instance Exception ToEventRawException
481481
482−decode :: MonadResource m => B.ByteString
483−#if MIN_VERSION_conduit(1, 0, 0)
484− -> Producer m Event
485−#else
486− -> GSource m Event
487−#endif
482+decode :: MonadResource m => B.ByteString -> Producer m Event
488483decode bs | B8.null bs = return ()
489484decode bs =
490485 bracketP alloc cleanup (runParser . fst)
@@ -526,12 +521,7 @@ openFile file rawOpenFlags openMode = do
526521 then withCString openMode $ \openMode' -> c_fdopen fd openMode'
527522 else return nullPtr
528523
529−decodeFile :: MonadResource m => FilePath
530−#if MIN_VERSION_conduit(1, 0, 0)
531− -> Producer m Event
532−#else
533− -> GSource m Event
534−#endif
524+decodeFile :: MonadResource m => FilePath -> Producer m Event
535525decodeFile file =
536526 bracketP alloc cleanup (runParser . fst)
537527 where
@@ -559,12 +549,7 @@ decodeFile file =
559549 c_yaml_parser_delete ptr
560550 free ptr
561551
562−runParser :: MonadResource m => Parser
563−#if MIN_VERSION_conduit(1, 0, 0)
564− -> Producer m Event
565−#else
566− -> GSource m Event
567−#endif
552+runParser :: MonadResource m => Parser -> Producer m Event
568553runParser parser = do
569554 e <- liftIO $ parserParseOne' parser
570555 case e of
@@ -588,12 +573,7 @@ parserParseOne' parser = allocaBytes eventSize $ \er -> do
588573 return $ Left $ YamlParseException problem context problemMark
589574 else Right <$> getEvent er
590575
591−encode :: MonadResource m
592−#if MIN_VERSION_conduit(1, 0, 0)
593− => Consumer Event m ByteString
594−#else
595− => GSink Event m ByteString
596−#endif
576+encode :: MonadResource m => Consumer Event m ByteString
597577encode =
598578 runEmitter alloc close
599579 where
@@ -610,11 +590,7 @@ encode =
610590
611591encodeFile :: MonadResource m
612592 => FilePath
613−#if MIN_VERSION_conduit(1, 0, 0)
614593 -> Consumer Event m ()
615−#else
616− -> GInfSink Event m
617−#endif
618594encodeFile filePath =
619595 bracketP getFile c_fclose $ \file -> runEmitter (alloc file) (\u _ -> return u)
620596 where
@@ -628,13 +604,8 @@ encodeFile filePath =
628604
629605runEmitter :: MonadResource m
630606 => (Emitter -> IO a) -- ^ alloc
631−#if MIN_VERSION_conduit(1, 0, 0)
632607 -> (() -> a -> IO b) -- ^ close
633608 -> Consumer Event m b
634−#else
635− -> (u -> a -> IO b) -- ^ close
636− -> Pipe l Event o u m b
637−#endif
638609runEmitter allocI closeI =
639610 bracketP alloc cleanup go
640611 where
@@ -654,11 +625,7 @@ runEmitter allocI closeI =
654625 go (emitter, a) =
655626 loop
656627 where
657−#if MIN_VERSION_conduit(1, 0, 0)
658628 loop = await >>= maybe (close ()) push
659−#else
660− loop = awaitE >>= either close push
661−#endif
662629
663630 push e = do
664631 _ <- liftIO $ toEventRaw e $ c_yaml_emitter_emit emitter