conduit-zstd-0.0.2.0/Data/0000755000000000000000000000000013240314264013334 5ustar0000000000000000conduit-zstd-0.0.2.0/Data/Conduit/0000755000000000000000000000000013661561546014757 5ustar0000000000000000conduit-zstd-0.0.2.0/tests/0000755000000000000000000000000013661556536013646 5ustar0000000000000000conduit-zstd-0.0.2.0/Data/Conduit/Zstd.hs0000644000000000000000000000217513661556536016247 0ustar0000000000000000module Data.Conduit.Zstd ( compress , decompress ) where import qualified Data.Conduit as C import qualified Data.ByteString as B import qualified Codec.Compression.Zstd.Streaming as Z import Control.Monad.IO.Class (MonadIO, liftIO) import Control.Exception.Base (throwIO) import System.IO.Error (userError) import Data.Maybe (fromMaybe) -- | compression conduit compress :: MonadIO m => Int -- ^ compression level -> C.ConduitT B.ByteString B.ByteString m () compress level = liftIO (Z.compress level) >>= go -- | decompression conduit decompress :: MonadIO m => C.ConduitT B.ByteString B.ByteString m () decompress = liftIO Z.decompress >>= go go :: MonadIO m => Z.Result -> C.ConduitT B.ByteString B.ByteString m () go (Z.Produce r next) = do C.yield r liftIO next >>= go go input@(Z.Consume f) = do next <- C.await case next of Just chunk | B.null chunk -> go input _ -> liftIO (f $ fromMaybe B.empty next) >>= go go (Z.Error m e) = liftIO (throwIO $ userError ("ZStandard error :" ++ m ++ ": " ++ e)) go (Z.Done r) = C.yield r conduit-zstd-0.0.2.0/tests/Tests.hs0000644000000000000000000000114513661556536015305 0ustar0000000000000000{- Copyright 2018 Luis Pedro Coelho - License: MIT -} {-# LANGUAGE TemplateHaskell, QuasiQuotes, FlexibleContexts, OverloadedStrings #-} module Main where import Test.Tasty import Test.Tasty.QuickCheck import Test.QuickCheck.Instances () import qualified Data.ByteString as B import Conduit import Data.Conduit.List (sourceList) import Data.Conduit.Zstd tests :: TestTree tests = testProperty "roundtrip" $ \input -> ioProperty $ do output' <- runConduit (sourceList input .| compress 1 .| decompress .| sinkList) pure $ B.concat input === B.concat output' main :: IO () main = defaultMain tests conduit-zstd-0.0.2.0/COPYING0000644000000000000000000000207213141661452013523 0ustar0000000000000000Copyright (c) 2017 Luis Pedro Coelho Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. conduit-zstd-0.0.2.0/conduit-zstd.cabal0000644000000000000000000000330213661561605016106 0ustar0000000000000000cabal-version: 1.12 -- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack -- -- hash: d730a92da866d784257a2ed593c3cb0ab481913627b9558c473171afbf32f4e8 name: conduit-zstd version: 0.0.2.0 synopsis: Conduit-based ZStd Compression description: Zstandard compression packaged as a conduit. This is a very thin wrapper around the [official hs-zstd interface](https://github.com/facebookexperimental/hs-zstd/) category: Conduit homepage: https://github.com/luispedro/conduit-zstd#readme bug-reports: https://github.com/luispedro/conduit-zstd/issues author: Luis Pedro Coelho maintainer: Luis Pedro Coelho license: MIT license-file: COPYING build-type: Simple extra-source-files: README.md ChangeLog source-repository head type: git location: https://github.com/luispedro/conduit-zstd library exposed-modules: Data.Conduit.Zstd default-extensions: BangPatterns OverloadedStrings LambdaCase TupleSections ghc-options: -Wall build-depends: base >4.8 && <5 , bytestring , conduit >=1.0 , zstd default-language: Haskell2010 test-suite conduit-zstd-test type: exitcode-stdio-1.0 main-is: Tests.hs other-modules: Data.Conduit.Zstd Paths_conduit_zstd hs-source-dirs: ./. ./tests default-extensions: BangPatterns OverloadedStrings LambdaCase TupleSections ghc-options: -Wall build-depends: base >4.8 && <5 , bytestring , conduit , conduit-combinators , conduit-extra , conduit-zstd , directory , quickcheck-instances , tasty , tasty-quickcheck , zstd default-language: Haskell2010 conduit-zstd-0.0.2.0/README.md0000644000000000000000000000113413661556536013762 0ustar0000000000000000# ZStandard conduit wrappers [![Hackage](https://img.shields.io/hackage/v/conduit-zstd.svg)](https://hackage.haskell.org/package/conduit-zstd) [![Hackage-Deps](https://img.shields.io/hackage-deps/v/conduit-zstd.svg)](http://packdeps.haskellers.com/feed?needle=conduit-zstd) [![Travis](https://api.travis-ci.com/luispedro/conduit-zstd.png)](https://travis-ci.com/luispedro/conduit-zstd) ZStandard compression as a Conduit Very thin wrapper around the [hs-zstd](https://github.com/facebookexperimental/hs-zstd) Haskell bindings for the [ZStandard compresssion library](http://facebook.github.io/zstd/). conduit-zstd-0.0.2.0/ChangeLog0000644000000000000000000000040513661556715014254 0ustar0000000000000000Version 0.0.2.0 2020-05-21 by luispedro * Do not stop if an empty bytestring is present in the stream (PR #1 by Kamil Dworakowski) Version 0.0.1.1 2018-09-23 by luispedro * Update to newer conduit API Version 0.0.1 2018-02-12 by luispedro * First version