base 4.10 compatibility (Semigroup)
Tested on lts-8 through pre-12 (nightly)
This commit is contained in:
parent
6352a5a4d4
commit
1646cfe755
@ -5,6 +5,7 @@ import Data.ByteString (ByteString)
|
|||||||
import qualified Data.ByteString.Lazy as BSL
|
import qualified Data.ByteString.Lazy as BSL
|
||||||
import qualified Data.Conduit as C
|
import qualified Data.Conduit as C
|
||||||
import Data.Conduit.Binary (sourceLbs)
|
import Data.Conduit.Binary (sourceLbs)
|
||||||
|
import Data.Semigroup (Semigroup(..))
|
||||||
import Data.String (IsString(..))
|
import Data.String (IsString(..))
|
||||||
import Data.Time.LocalTime (LocalTime)
|
import Data.Time.LocalTime (LocalTime)
|
||||||
import Data.Typeable (Typeable)
|
import Data.Typeable (Typeable)
|
||||||
@ -36,15 +37,18 @@ data ZipEntry = ZipEntry
|
|||||||
-- |The data contents for a 'ZipEntry'. For empty entries (e.g., directories), use 'mempty'.
|
-- |The data contents for a 'ZipEntry'. For empty entries (e.g., directories), use 'mempty'.
|
||||||
data ZipData m
|
data ZipData m
|
||||||
= ZipDataByteString BSL.ByteString -- ^A known ByteString, which will be fully evaluated (not streamed)
|
= ZipDataByteString BSL.ByteString -- ^A known ByteString, which will be fully evaluated (not streamed)
|
||||||
| ZipDataSource (C.Source m ByteString) -- ^A byte stream producer, streamed (and compressed) directly into the zip
|
| ZipDataSource (C.ConduitM () ByteString m ()) -- ^A byte stream producer, streamed (and compressed) directly into the zip
|
||||||
|
|
||||||
|
instance Monad m => Semigroup (ZipData m) where
|
||||||
|
ZipDataByteString a <> ZipDataByteString b = ZipDataByteString $ mappend a b
|
||||||
|
a <> b = ZipDataSource $ mappend (sourceZipData a) (sourceZipData b)
|
||||||
|
|
||||||
instance Monad m => Monoid (ZipData m) where
|
instance Monad m => Monoid (ZipData m) where
|
||||||
mempty = ZipDataByteString BSL.empty
|
mempty = ZipDataByteString BSL.empty
|
||||||
mappend (ZipDataByteString a) (ZipDataByteString b) = ZipDataByteString $ mappend a b
|
mappend = (<>)
|
||||||
mappend a b = ZipDataSource $ mappend (sourceZipData a) (sourceZipData b)
|
|
||||||
|
|
||||||
-- |Normalize any 'ZipData' to a simple source
|
-- |Normalize any 'ZipData' to a simple source
|
||||||
sourceZipData :: Monad m => ZipData m -> C.Source m ByteString
|
sourceZipData :: Monad m => ZipData m -> C.ConduitM () ByteString m ()
|
||||||
sourceZipData (ZipDataByteString b) = sourceLbs b
|
sourceZipData (ZipDataByteString b) = sourceLbs b
|
||||||
sourceZipData (ZipDataSource s) = s
|
sourceZipData (ZipDataSource s) = s
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ library
|
|||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
ghc-options: -Wall -Werror
|
ghc-options: -Wall -Werror
|
||||||
build-depends:
|
build-depends:
|
||||||
base >= 4.8 && < 5,
|
base >= 4.9 && < 5,
|
||||||
binary >= 0.7.2,
|
binary >= 0.7.2,
|
||||||
binary-conduit,
|
binary-conduit,
|
||||||
bytestring,
|
bytestring,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user