From 316d3e5e93cb8cac684d62e0f005ebf017ed56cd Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 2 Jan 2022 02:19:35 -0500 Subject: [PATCH] Use `base-orphans` to make the GHC.Generics instances unconditional Fixes #8 --- groups.cabal | 5 ++++- src/Data/Group.hs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/groups.cabal b/groups.cabal index d88b3e3..1ca3cf1 100644 --- a/groups.cabal +++ b/groups.cabal @@ -19,6 +19,9 @@ source-repository head library exposed-modules: Data.Group -- other-modules: - build-depends: base >= 4.6 && < 5 hs-source-dirs: src default-language: Haskell2010 + build-depends: base >= 4.6 && < 5 + + if impl(ghc < 8.6) -- really, if base < 8.12 + build-depends: base-orphans >= 0.8 && < 0.9 diff --git a/src/Data/Group.hs b/src/Data/Group.hs index 6aec99e..c208a38 100644 --- a/src/Data/Group.hs +++ b/src/Data/Group.hs @@ -197,7 +197,6 @@ instance Cyclic a => Cyclic (Identity a) where -- (:*:) and (:.:) exist since base-4.6.0.0 but the Monoid instances -- arrive in base-4.12.0.0. -- Also, contravariant was moved into base in this version. -#if MIN_VERSION_base(4,12,0) -- | Product of groups, Functor style. instance (Group (f a), Group (g a)) => Group ((f :*: g) a) where invert (a :*: b) = invert a :*: invert b @@ -214,6 +213,7 @@ instance (Abelian (f a), Abelian (g a)) => Abelian ((f :*: g) a) instance Abelian (f (g a)) => Abelian ((f :.: g) a) +#if MIN_VERSION_base(4,12,0) instance Group a => Group (Op a b) where invert (Op f) = Op (invert f) pow (Op f) n = Op (\e -> pow (f e) n)