    -- Compression.hs: OpenPGP (RFC4880) compression conduits
    -- Copyright © 2012-2018  Clint Adams
    -- This software is released under the terms of the Expat license.
    -- (See the LICENSE file).
    module Data.Conduit.OpenPGP.Compression
      ( conduitCompress
      , conduitDecompress
      ) where

    import Codec.Encryption.OpenPGP.Compression
    import Codec.Encryption.OpenPGP.Types
    import Control.Monad.Trans.Resource (MonadThrow)
    import Data.Conduit
    import qualified Data.Conduit.List as CL

    conduitCompress :: MonadThrow m => CompressionAlgorithm -> ConduitT Pkt Pkt m ()
    conduitCompress :: CompressionAlgorithm -> ConduitT Pkt Pkt m ()
    conduitCompress algo :: CompressionAlgorithm
    algo = ConduitT Pkt Pkt m [Pkt]
    forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
    CL.consume ConduitT Pkt Pkt m [Pkt]
    -> ([Pkt] -> ConduitT Pkt Pkt m ()) -> ConduitT Pkt Pkt m ()
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \ps :: [Pkt]
    ps -> Pkt -> ConduitT Pkt Pkt m ()
    forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
    yield (CompressionAlgorithm -> [Pkt] -> Pkt
    compressPkts CompressionAlgorithm
    algo [Pkt]
    ps)

    conduitDecompress :: MonadThrow m => ConduitT Pkt Pkt m ()
    conduitDecompress :: ConduitT Pkt Pkt m ()
    conduitDecompress = (Pkt -> [Pkt]) -> ConduitT Pkt Pkt m ()
    forall (m :: * -> *) a b.
    Monad m =>
    (a -> [b]) -> ConduitT a b m ()
    CL.concatMap Pkt -> [Pkt]
    decompressPkt