Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion constrained-generators.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ library
-Wunused-packages

build-depends:
QuickCheck >=2.14,
QuickCheck >=2.14 && <2.18,
base >=4.18 && <5,
base-orphans,
containers,
Expand Down
9 changes: 8 additions & 1 deletion src/Constrained/Core.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ImportQualifiedPost #-}
Expand Down Expand Up @@ -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 --------------------------------------------------------------

Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/Constrained/NumOrd.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DerivingVia #-}
Expand Down Expand Up @@ -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
Expand Down