diff --git a/cabal.project b/cabal.project index 1671440..5c0072e 100644 --- a/cabal.project +++ b/cabal.project @@ -1,2 +1,9 @@ packages: . +-- Always write GHC env files, because they are needed for repl and by the doctests. +write-ghc-environment-files: always +-- Always build tests and benchmarks. +tests: true +benchmarks: true +-- The only sensible test display option +test-show-details: streaming diff --git a/constrained-generators.cabal b/constrained-generators.cabal index a271f63..1b487af 100644 --- a/constrained-generators.cabal +++ b/constrained-generators.cabal @@ -79,7 +79,7 @@ library -Wunused-packages build-depends: - QuickCheck >=2.14, + QuickCheck >=2.14 && <2.18, base >=4.18 && <5, base-orphans, containers, diff --git a/src/Constrained/Core.hs b/src/Constrained/Core.hs index 95714e3..e4e14e3 100644 --- a/src/Constrained/Core.hs +++ b/src/Constrained/Core.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE ImportQualifiedPost #-} @@ -35,11 +36,15 @@ import Constrained.PrettyUtils import Control.Applicative import Data.Function import Data.List.NonEmpty (NonEmpty ((:|))) -import Data.List.NonEmpty qualified as NE import Data.Set (Set) import Data.Set qualified as Set import Data.Typeable + +-- Orphan instance for old QuickCheck versions +#if !MIN_VERSION_QuickCheck(2, 17, 0) +import Data.List.NonEmpty qualified as NE import Test.QuickCheck (Arbitrary (..), NonEmptyList (NonEmpty)) +#endif -- Variables -------------------------------------------------------------- @@ -135,7 +140,9 @@ instance Typeable c => Show (Evidence c) where unionWithMaybe :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a unionWithMaybe f ma ma' = (f <$> ma <*> ma') <|> ma <|> ma' +#if !MIN_VERSION_QuickCheck(2, 17, 0) instance Arbitrary a => Arbitrary (NonEmpty a) where arbitrary = do NonEmpty xs <- arbitrary pure (NE.fromList xs) +#endif diff --git a/src/Constrained/NumOrd.hs b/src/Constrained/NumOrd.hs index cccd3f2..df4027a 100644 --- a/src/Constrained/NumOrd.hs +++ b/src/Constrained/NumOrd.hs @@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DerivingVia #-} @@ -257,9 +258,11 @@ instance (Arbitrary a, Ord a) => Arbitrary (NumSpec a) where shrink (NumSpecInterval m m') = uncurry NumSpecInterval <$> shrink (m, m') +#if !MIN_VERSION_QuickCheck(2, 17, 0) instance Arbitrary Natural where arbitrary = wordToNatural . abs <$> arbitrary shrink n = [wordToNatural w | w <- shrink (naturalToWord n)] +#endif instance Uniform Natural where uniformM g = wordToNatural . abs <$> uniformM g