Skip to content

Commit 1b364cb

Browse files
committed
Fix building with older ghc
Should work with 6.10 to 7.10
1 parent 898e696 commit 1b364cb

File tree

3 files changed

+44
-9
lines changed

3 files changed

+44
-9
lines changed

Codec/Compression/Zlib/Internal.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{-# LANGUAGE CPP, RankNTypes, DeriveDataTypeable, BangPatterns #-}
2+
#if __GLASGOW_HASKELL__ >= 702
23
{-# LANGUAGE Trustworthy #-}
4+
#endif
35
-----------------------------------------------------------------------------
46
-- |
57
-- Copyright : (c) 2006-2014 Duncan Coutts

Codec/Compression/Zlib/Stream.hsc

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
{-# LANGUAGE ForeignFunctionInterface, DeriveDataTypeable, DeriveGeneric #-}
1+
{-# LANGUAGE CPP, ForeignFunctionInterface, DeriveDataTypeable #-}
2+
#if __GLASGOW_HASKELL__ >= 702
3+
{-# LANGUAGE DeriveGeneric #-}
4+
#endif
25
-----------------------------------------------------------------------------
36
-- |
47
-- Copyright : (c) 2006-2014 Duncan Coutts
@@ -119,7 +122,9 @@ import Control.Monad.ST.Strict
119122
#endif
120123
import Control.Exception (assert)
121124
import Data.Typeable (Typeable)
125+
#if __GLASGOW_HASKELL__ >= 702
122126
import GHC.Generics (Generic)
127+
#endif
123128
#ifdef DEBUG
124129
import System.IO (hPutStrLn, stderr)
125130
#endif
@@ -565,7 +570,11 @@ fromFlush Finish = #{const Z_FINISH}
565570
-- variations.
566571
--
567572
data Format = GZip | Zlib | Raw | GZipOrZlib
568-
deriving (Eq, Ord, Enum, Bounded, Show, Typeable, Generic)
573+
deriving (Eq, Ord, Enum, Bounded, Show, Typeable
574+
#if __GLASGOW_HASKELL__ >= 702
575+
, Generic
576+
#endif
577+
)
569578

570579
{-# DEPRECATED GZip "Use gzipFormat. Format constructors will be hidden in version 0.7" #-}
571580
{-# DEPRECATED Zlib "Use zlibFormat. Format constructors will be hidden in version 0.7" #-}
@@ -610,7 +619,11 @@ formatSupportsDictionary _ = False
610619
-- | The compression method
611620
--
612621
data Method = Deflated
613-
deriving (Eq, Ord, Enum, Bounded, Show, Typeable, Generic)
622+
deriving (Eq, Ord, Enum, Bounded, Show, Typeable
623+
#if __GLASGOW_HASKELL__ >= 702
624+
, Generic
625+
#endif
626+
)
614627

615628
{-# DEPRECATED Deflated "Use deflateMethod. Method constructors will be hidden in version 0.7" #-}
616629

@@ -634,7 +647,11 @@ data CompressionLevel =
634647
| BestSpeed
635648
| BestCompression
636649
| CompressionLevel Int
637-
deriving (Eq, Show, Typeable, Generic)
650+
deriving (Eq, Show, Typeable
651+
#if __GLASGOW_HASKELL__ >= 702
652+
, Generic
653+
#endif
654+
)
638655

639656
{-# DEPRECATED DefaultCompression "Use defaultCompression. CompressionLevel constructors will be hidden in version 0.7" #-}
640657
{-# DEPRECATED NoCompression "Use noCompression. CompressionLevel constructors will be hidden in version 0.7" #-}
@@ -694,7 +711,11 @@ data WindowBits = WindowBits Int
694711
-- is defined with and used by the tests.
695712
-- It makse sense because the default value
696713
-- is is also the max value at 15.
697-
deriving (Eq, Show, Typeable, Generic)
714+
deriving (Eq, Show, Typeable
715+
#if __GLASGOW_HASKELL__ >= 702
716+
, Generic
717+
#endif
718+
)
698719

699720
{-# DEPRECATED DefaultWindowBits "Use defaultWindowBits. WindowBits constructors will be hidden in version 0.7" #-}
700721
--FIXME: cannot deprecate constructor named the same as the type
@@ -750,7 +771,11 @@ data MemoryLevel =
750771
| MinMemoryLevel
751772
| MaxMemoryLevel
752773
| MemoryLevel Int
753-
deriving (Eq, Show, Typeable, Generic)
774+
deriving (Eq, Show, Typeable
775+
#if __GLASGOW_HASKELL__ >= 702
776+
, Generic
777+
#endif
778+
)
754779

755780
{-# DEPRECATED DefaultMemoryLevel "Use defaultMemoryLevel. MemoryLevel constructors will be hidden in version 0.7" #-}
756781
{-# DEPRECATED MinMemoryLevel "Use minMemoryLevel. MemoryLevel constructors will be hidden in version 0.7" #-}
@@ -800,7 +825,11 @@ data CompressionStrategy =
800825
DefaultStrategy
801826
| Filtered
802827
| HuffmanOnly
803-
deriving (Eq, Ord, Enum, Bounded, Show, Typeable, Generic)
828+
deriving (Eq, Ord, Enum, Bounded, Show, Typeable
829+
#if __GLASGOW_HASKELL__ >= 702
830+
, Generic
831+
#endif
832+
)
804833

805834
{-
806835
-- -- only available in zlib 1.2 and later, uncomment if you need it.

zlib.cabal

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ library
4343
else
4444
default-language: Haskell2010
4545
other-extensions: CPP, ForeignFunctionInterface, RankNTypes, BangPatterns,
46-
DeriveDataTypeable, DeriveGeneric
47-
build-depends: base >= 3 && < 5,
46+
DeriveDataTypeable
47+
if impl(ghc >= 7.2)
48+
other-extensions: DeriveGeneric
49+
build-depends: base >= 4 && < 5,
4850
bytestring >= 0.9 && < 0.12
51+
if impl(ghc >= 7.2 && < 7.6)
52+
build-depends: ghc-prim
4953
includes: zlib.h
5054
ghc-options: -Wall -fwarn-tabs
5155
if !os(windows)

0 commit comments

Comments
 (0)