Permalink
Browse files

Fallback on generic-deriving for GHC.Generics on older GHC

  • Loading branch information...
1 parent f7223b3 commit a78f0b24fd1fee9f53188ff31d6b96b354c64682 @dag dag committed Dec 5, 2012
Showing with 24 additions and 4 deletions.
  1. +4 −0 benchmarks/plated.hs
  2. +8 −3 lens.cabal
  3. +12 −1 src/GHC/Generics/Lens.hs
View
@@ -14,7 +14,11 @@ import qualified Data.Generics.Uniplate.Direct as Uni
import Data.Generics.Uniplate.Direct ((|*))
import qualified Data.Generics.Uniplate.DataOnly as UniDataOnly
#endif
+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702
import GHC.Generics
+#else
+import Generics.Deriving
+#endif
import GHC.Generics.Lens as Generic
data Expr = Val !Int
View
@@ -220,6 +220,7 @@ library
Data.Typeable.Lens
Data.Vector.Lens
Data.Vector.Generic.Lens
+ GHC.Generics.Lens
other-modules:
Control.Lens.Internal.Combinators
@@ -249,10 +250,11 @@ library
if !flag(inlining)
cpp-options: -DOMIT_INLINING
- if impl(ghc>=7.4)
+ if impl(ghc>=7.2)
other-extensions: Trustworthy
build-depends: ghc-prim
- exposed-modules: GHC.Generics.Lens
+ else
+ build-depends: generic-deriving
ghc-options: -Wall -fwarn-tabs -O2 -fdicts-cheap -funbox-strict-fields
hs-source-dirs: src
@@ -334,9 +336,12 @@ benchmark plated
comonad,
criterion,
deepseq,
- ghc-prim,
lens,
transformers
+ if impl(ghc>=7.2)
+ build-depends: ghc-prim
+ else
+ build-depends: generic-deriving
ghc-options: -Wall -O2 -threaded -fdicts-cheap -funbox-strict-fields
hs-source-dirs: benchmarks
if flag(benchmark-uniplate)
View
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
@@ -23,6 +24,11 @@
-- You can use 'generic' to replace 'GHC.Generics.from' and 'GHC.Generics.to' from @GHC.Generics@,
-- and probably won't be explicitly referencing 'Control.Lens.Representable.Rep' from @Control.Lens@
-- in code that uses generics.
+--
+-- If you're using a version of GHC older than 7.2, this module is
+-- compatible with the
+-- <http://hackage.haskell.org/package/generic-deriving generic-deriving>
+-- package.
----------------------------------------------------------------------------
module GHC.Generics.Lens
(
@@ -38,8 +44,13 @@ import Control.Applicative
import Control.Lens hiding (Rep)
import Data.Maybe (fromJust)
import Data.Typeable
+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702
import qualified GHC.Generics as Generic
-import GHC.Generics hiding (from, to)
+import GHC.Generics hiding (from, to)
+#else
+import qualified Generics.Deriving as Generic
+import Generics.Deriving hiding (from, to)
+#endif
-- | Convert from the data type to its representation (or back)
--

0 comments on commit a78f0b2

Please sign in to comment.