Skip to content

Commit 2b68967

Browse files
Deal with breaking change in QuickCheck (#43)
* Deal with breaking change in QuickCheck * force build the tests - why is this necessary now!? * Update cabal.project Co-authored-by: Alexey Kuleshevich <[email protected]> * bounds on QuickCheck version --------- Co-authored-by: Alexey Kuleshevich <[email protected]>
1 parent 4ccd6b0 commit 2b68967

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

cabal.project

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
packages:
22
.
3+
-- Always write GHC env files, because they are needed for repl and by the doctests.
4+
write-ghc-environment-files: always
5+
-- Always build tests and benchmarks.
6+
tests: true
7+
benchmarks: true
8+
-- The only sensible test display option
9+
test-show-details: streaming

constrained-generators.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ library
7979
-Wunused-packages
8080

8181
build-depends:
82-
QuickCheck >=2.14,
82+
QuickCheck >=2.14 && <2.18,
8383
base >=4.18 && <5,
8484
base-orphans,
8585
containers,

src/Constrained/Core.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE FlexibleInstances #-}
23
{-# LANGUAGE GADTs #-}
34
{-# LANGUAGE ImportQualifiedPost #-}
@@ -35,11 +36,15 @@ import Constrained.PrettyUtils
3536
import Control.Applicative
3637
import Data.Function
3738
import Data.List.NonEmpty (NonEmpty ((:|)))
38-
import Data.List.NonEmpty qualified as NE
3939
import Data.Set (Set)
4040
import Data.Set qualified as Set
4141
import Data.Typeable
42+
43+
-- Orphan instance for old QuickCheck versions
44+
#if !MIN_VERSION_QuickCheck(2, 17, 0)
45+
import Data.List.NonEmpty qualified as NE
4246
import Test.QuickCheck (Arbitrary (..), NonEmptyList (NonEmpty))
47+
#endif
4348

4449
-- Variables --------------------------------------------------------------
4550

@@ -135,7 +140,9 @@ instance Typeable c => Show (Evidence c) where
135140
unionWithMaybe :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a
136141
unionWithMaybe f ma ma' = (f <$> ma <*> ma') <|> ma <|> ma'
137142

143+
#if !MIN_VERSION_QuickCheck(2, 17, 0)
138144
instance Arbitrary a => Arbitrary (NonEmpty a) where
139145
arbitrary = do
140146
NonEmpty xs <- arbitrary
141147
pure (NE.fromList xs)
148+
#endif

src/Constrained/NumOrd.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE AllowAmbiguousTypes #-}
22
{-# LANGUAGE ConstraintKinds #-}
3+
{-# LANGUAGE CPP #-}
34
{-# LANGUAGE DataKinds #-}
45
{-# LANGUAGE DefaultSignatures #-}
56
{-# LANGUAGE DerivingVia #-}
@@ -257,9 +258,11 @@ instance (Arbitrary a, Ord a) => Arbitrary (NumSpec a) where
257258
shrink (NumSpecInterval m m') =
258259
uncurry NumSpecInterval <$> shrink (m, m')
259260

261+
#if !MIN_VERSION_QuickCheck(2, 17, 0)
260262
instance Arbitrary Natural where
261263
arbitrary = wordToNatural . abs <$> arbitrary
262264
shrink n = [wordToNatural w | w <- shrink (naturalToWord n)]
265+
#endif
263266

264267
instance Uniform Natural where
265268
uniformM g = wordToNatural . abs <$> uniformM g

0 commit comments

Comments
 (0)