diff --git a/.gitignore b/.gitignore index db4503f..507555a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ dist-newstyle +dist-mcabal .ghc.environment.* cabal.project.local diff --git a/OneTuple.cabal b/OneTuple.cabal index 86f2e50..aec892d 100644 --- a/OneTuple.cabal +++ b/OneTuple.cabal @@ -45,22 +45,26 @@ library exposed-modules: Data.Tuple.OneTuple Data.Tuple.Solo - Data.Tuple.Solo.TH + + if impl(ghc) + exposed-modules: + Data.Tuple.Solo.TH + build-depends: + template-haskell hs-source-dirs: src build-depends: base >=4.12 && <4.23 - , template-haskell if impl(ghc >=9.0) build-depends: ghc-prim else - build-depends: hashable >=1.3.5.0 && <1.6 + build-depends: hashable >=1.2.5.0 && <1.6 - if !impl(ghc >=9.0) + if impl(ghc) && !impl(ghc >=9.0) build-depends: foldable1-classes-compat >=0.1 && <0.2 - if !impl(ghc >=9.2) + if impl(ghc) && !impl(ghc >=9.2) build-depends: base-orphans >=0.8.6 test-suite instances @@ -73,13 +77,13 @@ test-suite instances , hashable , OneTuple - if !impl(ghc >=8.0) + if impl(ghc) && !impl(ghc >=8.0) build-depends: semigroups , transformers , transformers-compat - if !impl(ghc >=9.6) + if impl(ghc) && !impl(ghc >=9.6) build-depends: foldable1-classes-compat >=0.1 && <0.2 test-suite th @@ -87,6 +91,8 @@ test-suite th default-language: Haskell98 hs-source-dirs: test main-is: th.hs + if !impl(ghc) + buildable: False build-depends: base , OneTuple diff --git a/src/Data/Tuple/Solo.hs b/src/Data/Tuple/Solo.hs index 1814d2b..d72325d 100644 --- a/src/Data/Tuple/Solo.hs +++ b/src/Data/Tuple/Solo.hs @@ -30,7 +30,23 @@ module Data.Tuple.Solo ( import Data.Orphans () #endif -#if MIN_VERSION_base(4,18,0) +#if defined(MIN_VERSION_hashable) +#if !MIN_VERSION_hashable(1,3,5) || defined(__GLASGOW_HASKELL__) +import Data.Hashable (Hashable (..)) +import Data.Hashable.Lifted (Hashable1 (..), hashWithSalt1) +#endif +#endif + +#if defined(__MHS__) +import Data.Tuple (Solo (MkSolo), getSolo) + +pattern Solo :: a -> Solo a +pattern Solo a = Solo a + +{-# COMPLETE Solo #-} + + +#elif MIN_VERSION_base(4,18,0) import GHC.Tuple (Solo (MkSolo, Solo), getSolo) @@ -72,11 +88,6 @@ import qualified Data.Foldable1 as F1 import Data.Functor.Classes (Eq1 (..), Ord1 (..), Show1 (..), Read1 (..)) -#if !(MIN_VERSION_base(4,15,0)) -import Data.Hashable (Hashable (..)) -import Data.Hashable.Lifted (Hashable1 (..), hashWithSalt1) -#endif - import Data.Functor.Classes (readData, readUnaryWith, liftReadListDefault, liftReadListPrecDefault) import GHC.Generics (Generic, Generic1) import Control.Monad.Zip (MonadZip (..)) @@ -188,7 +199,8 @@ instance Show1 Solo where showString "MkSolo " . sp 11 x #endif -#if !(MIN_VERSION_base(4,15,0)) +#if defined(MIN_VERSION_hashable) +#if !MIN_VERSION_hashable(1,3,5) || defined(__GLASGOW_HASKELL__) -- | @since 0.3.1 instance Hashable a => Hashable (Solo a) where hashWithSalt = hashWithSalt1 @@ -197,3 +209,4 @@ instance Hashable a => Hashable (Solo a) where instance Hashable1 Solo where liftHashWithSalt h salt (MkSolo a) = h salt a #endif +#endif