conduit-zstd (empty) → 0.0.1.0
raw patch · 7 files changed
+156/−0 lines, 7 filesdep +HUnitdep +basedep +bytestringsetup-changed
Dependencies added: HUnit, base, bytestring, conduit, conduit-combinators, conduit-extra, conduit-zstd, directory, test-framework, test-framework-hunit, test-framework-th, zstd
Files
- COPYING +23/−0
- ChangeLog +2/−0
- Data/Conduit/Zstd.hs +33/−0
- README.md +6/−0
- Setup.hs +2/−0
- conduit-zstd.cabal +65/−0
- tests/Tests.hs +25/−0
+ COPYING view
@@ -0,0 +1,23 @@+Copyright (c) 2017+Luis Pedro Coelho <luis@luispedro.org>++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.
+ ChangeLog view
@@ -0,0 +1,2 @@+Version 0.0.1 2018-02-12 by luispedro+ * First version
+ Data/Conduit/Zstd.hs view
@@ -0,0 +1,33 @@+module 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.Conduit B.ByteString m B.ByteString+compress level = liftIO (Z.compress level) >>= go++-- | decompression conduit+decompress :: MonadIO m => C.Conduit B.ByteString m B.ByteString+decompress = liftIO Z.decompress >>= go++go :: MonadIO m => Z.Result -> C.Conduit B.ByteString m B.ByteString+go (Z.Produce r next) = do+ C.yield r+ liftIO next >>= go+go (Z.Consume f) = do+ next <- C.await+ 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
+ README.md view
@@ -0,0 +1,6 @@+# ZStandard conduit wrappers++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/).+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ conduit-zstd.cabal view
@@ -0,0 +1,65 @@+-- This file has been generated from package.yaml by hpack version 0.21.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: f895f93106c2227e098a21dc6fb09dbc63f3e67e7d73e05c07c035f64dd55450++name: conduit-zstd+version: 0.0.1.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+cabal-version: >= 1.10++extra-source-files:+ ChangeLog+ README.md++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:+ HUnit+ , base >4.8 && <5+ , bytestring+ , conduit+ , conduit-combinators+ , conduit-extra+ , conduit-zstd+ , directory+ , test-framework+ , test-framework-hunit+ , test-framework-th+ , zstd+ default-language: Haskell2010
+ tests/Tests.hs view
@@ -0,0 +1,25 @@+{- Copyright 2018 Luis Pedro Coelho+ - License: MIT+ -}+{-# LANGUAGE TemplateHaskell, QuasiQuotes, FlexibleContexts, OverloadedStrings #-}+module Main where++import Test.Framework.TH+import Test.HUnit+import Test.Framework.Providers.HUnit++import qualified Data.ByteString as B+import qualified Data.Conduit as C+import qualified Data.Conduit.Combinators as CC+import qualified Data.Conduit.List as CL+import Data.Conduit ((.|))++import qualified Data.Conduit.Zstd as CZ++main :: IO ()+main = $(defaultMainGenerator)++case_basic :: IO ()+case_basic = do+ hello <- B.concat <$> (C.runConduitRes (CC.yieldMany ["Hello", " ", "World"] .| CZ.compress 2 .| CZ.decompress .| CL.consume))+ hello @?= "Hello World"