packages feed

zlib-lens (empty) → 0.1

raw patch · 5 files changed

+292/−0 lines, 5 filesdep +basedep +bytestringdep +lenssetup-changed

Dependencies added: base, bytestring, lens, zlib

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2014, ++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of  nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,4 @@+zlib-lens+=========++Lenses for zlib
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Codec/Compression/Zlib/Lens.hs view
@@ -0,0 +1,231 @@+{-# LANGUAGE Rank2Types #-}+-----------------------------------------------------------------------------+-- |+-- Module      :  Codec.Compression.Zlib.Lens+-- Copyright   :  (C) 2012-14 Edward Kmett+-- License     :  BSD-style (see the file LICENSE)+-- Maintainer  :  Edward Kmett <ekmett@gmail.com>+-- Stability   :  provisional+-- Portability :  portable+--+-- @lens@ support for the @zlib@ library+----------------------------------------------------------------------------+module Codec.Compression.Zlib.Lens+  ( -- * High-Level API+    gzipped,+    zlibbed,+    deflated,+    compressed,+    Format,+    gzip,+    zlib,+    deflate,+    -- * Low-Level API+    zlibbed',+    gzipped',+    deflated',+    compressed',+    Params,+    defaultParams,+    levelC,+    methodC,+    windowBitsC,+    windowBitsD,+    memoryLevelC,+    strategyC,+    bufferSizeC,+    bufferSizeD,+    dictionary,+    CompressionLevel,+    defaultCompression,+    noCompression,+    bestSpeed,+    bestCompression,+    compressionLevel,+    Method,+    deflateMethod,+    WindowBits,+    defaultWindowBits,+    windowBits,+    MemoryLevel,+    defaultMemoryLevel,+    minMemoryLevel,+    maxMemoryLevel,+    memoryLevel,+    CompressionStrategy,+    defaultStrategy,+    filteredStrategy,+    huffmanOnlyStrategy+  ) where++import Control.Applicative+import Codec.Compression.Zlib.Internal+import Control.Lens+import qualified Data.ByteString      as S (ByteString)+import qualified Data.ByteString.Lazy as L (ByteString)++-- |+-- The 'zlib' compression format.+zlib :: Format+zlib = zlibFormat+{-# INLINE zlib #-}++-- |+-- The 'gzip' compression format.+gzip :: Format+gzip = gzipFormat+{-# INLINE gzip #-}++-- |+-- The 'deflate' compression format.+deflate :: Format+deflate = rawFormat+{-# INLINE deflate #-}++-- |+-- Compresses a 'L.ByteString' using the 'gzip' compression format.+--+-- @+-- 'gzipped' = 'compressed' 'gzip'+-- 'gzipped' = 'gzipped'' 'defaultParams'+-- @+gzipped :: Iso' L.ByteString L.ByteString+gzipped = compressed gzip+{-# INLINE gzipped #-}++-- |+-- Compresses a 'L.ByteString' using the 'zlib' compression format.+--+-- @+-- 'zlibbed' = 'compressed' 'zlib'+-- 'zlibbed' = 'zlibbed\'' 'defaultParams'+-- @+zlibbed :: Iso' L.ByteString L.ByteString+zlibbed = compressed zlib+{-# INLINE zlibbed #-}++-- |+-- Compresses a 'L.ByteString' using the 'deflate' compression format.+--+-- @+-- 'deflated' = 'compressed' 'deflate'+-- 'deflated' = 'deflated'' 'defaultParams'+-- @+deflated :: Iso' L.ByteString L.ByteString+deflated = compressed deflate+{-# INLINE deflated #-}++-- |+-- Compresses a 'L.ByteString' using the given compression format.+--+-- @+-- 'compressed' fmt = 'compressed'' fmt 'defaultParams'+-- @+compressed :: Format -> Iso' L.ByteString L.ByteString+compressed fmt = compressed' fmt defaultParams+{-# INLINE compressed #-}++-- |+-- Compresses a 'L.ByteString' using the 'gzip' compression format and the given advanced parameters.+--+-- @+-- 'gzipped' = 'compressed' 'gzip'+-- 'gzipped' = 'gzipped'' 'defaultParams'+-- @+gzipped' :: Params -> Iso' L.ByteString L.ByteString+gzipped' = compressed' gzip+{-# INLINE gzipped' #-}++-- |+-- Compresses a 'L.ByteString' using the 'zlib' compression format and the given advanced parameters.+--+-- @+-- 'zlibbed' = 'compressed' 'zlib'+-- 'zlibbed' = 'zlibbed'' 'defaultParams'+-- @+zlibbed' :: Params -> Iso' L.ByteString L.ByteString+zlibbed' = compressed' zlib+{-# INLINE zlibbed' #-}++-- |+-- Compresses a 'L.ByteString' using the 'deflate' compression format and the given advanced parameters.+--+-- @+-- 'deflated' = 'compressed' 'deflate'+-- 'deflated' = 'deflated'' 'defaultParams'+-- @+deflated' :: Params -> Iso' L.ByteString L.ByteString+deflated' = compressed' deflate+{-# INLINE deflated' #-}++-- |+-- Compresses a 'L.ByteString' using the given compression format and the given advanced parameters.+compressed' :: Format -> Params -> Iso' L.ByteString L.ByteString+compressed' fmt (Params c d) = iso (compress fmt c) (decompress fmt d)+{-# INLINE compressed' #-}++-- |+-- The advanced parameters needed by 'gzipped'', 'zlibbed'', 'deflated'', and 'compressed''.+--+-- Use 'defaultParams' and the provided 'Lens'es to construct custom 'Params'.+data Params = Params !CompressParams !DecompressParams++-- |+-- The default advanced parameters for compression and decompression.+defaultParams :: Params+defaultParams = Params defaultCompressParams defaultDecompressParams+{-# INLINE defaultParams #-}++-- |+-- The compression level.+levelC :: Lens' Params CompressionLevel+levelC = \ f (Params c d) -> (\l -> Params (c {compressLevel = l}) d) <$> f (compressLevel c)+{-# INLINE levelC #-}++-- |+-- The compression method.+methodC :: Lens' Params Method+methodC = \ f (Params c d) -> (\m -> Params (c {compressMethod = m}) d) <$> f (compressMethod c)+{-# INLINE methodC #-}++-- |+-- The number of bits in the compression window.+windowBitsC :: Lens' Params WindowBits+windowBitsC = \ f (Params c d) -> (\wb -> Params (c {compressWindowBits = wb}) d) <$> f (compressWindowBits c)+{-# INLINE windowBitsC #-}++-- |+-- The number of bits in the decompression window.+windowBitsD :: Lens' Params WindowBits+windowBitsD = \ f (Params c d) -> (\wb -> Params c (d {decompressWindowBits = wb})) <$> f (decompressWindowBits d)+{-# INLINE windowBitsD #-}++-- |+-- The amount of memory allowed for the internal compression state.+memoryLevelC :: Lens' Params MemoryLevel+memoryLevelC = \ f (Params c d) -> (\ml -> Params (c {compressMemoryLevel = ml}) d) <$> f (compressMemoryLevel c)+{-# INLINE memoryLevelC #-}++-- |+-- The compression strategy.+strategyC :: Lens' Params CompressionStrategy+strategyC = \ f (Params c d) -> (\s -> Params (c {compressStrategy = s}) d) <$> f (compressStrategy c)+{-# INLINE strategyC #-}++-- |+-- The initial buffer size during compression.+bufferSizeC :: Lens' Params Int+bufferSizeC = \ f (Params c d) -> (\bs -> Params (c {compressBufferSize = bs}) d) <$> f (compressBufferSize c)+{-# INLINE bufferSizeC #-}++-- |+-- The initial buffer size during decompression.+bufferSizeD :: Lens' Params Int+bufferSizeD = \ f (Params c d) -> (\bs -> Params c (d {decompressBufferSize = bs})) <$> f (decompressBufferSize d)+{-# INLINE bufferSizeD #-}++-- |+-- 'Just' the custom (de)compression dictionary to use, or 'Nothing' to not use a custom dictionary.+dictionary :: Lens' Params (Maybe S.ByteString)+dictionary = \f (Params c d) -> (\mbs -> Params (c {compressDictionary = mbs}) (d {decompressDictionary = mbs})) <$> f (compressDictionary c <|> decompressDictionary d)+{-# INLINE dictionary #-}
+ zlib-lens.cabal view
@@ -0,0 +1,25 @@+name:                zlib-lens+version:             0.1+synopsis:            Lenses for zlib+-- description:+homepage:            lens.github.io+license:             BSD3+license-file:        LICENSE+-- author:+maintainer:+-- copyright:+category:            Codec+build-type:          Simple+extra-source-files:  README.md+cabal-version:       >=1.10++library+  exposed-modules:     Codec.Compression.Zlib.Lens+  other-extensions:    Rank2Types+  build-depends:       base >=4.7 && <4.8,+                       bytestring >=0.10 && <0.11,+                       lens >=4.5 && < 5,+                       zlib >=0.5.4 && <0.6++  hs-source-dirs:      src+  default-language:    Haskell2010