Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Test.QuickCheck.Range
Description
Entenstion of QuickCheck's modifiers with Integral ranges with type defined bounds.
>>>
foo :: Range Int 0 255 -> Bool
>>>
foo (Range v) = /* ... */
(c) 2014-2019 Vladimír Štill
Synopsis
- type Range (i :: Type) (from :: Nat) (to :: Nat) = Ranges i '['(from, to)]
- newtype Ranges :: Type -> [(Nat, Nat)] -> Type where
- newtype CharRanges ranges = CharRange (Ranges Char ranges)
- unCharRange :: CharRanges ranges -> Char
- charRangeToRange :: CharRanges ranges -> Ranges Char ranges
- type CharRange (from :: Nat) (to :: Nat) = CharRanges '['(from, to)]
- type AsciiPrintableRange = CharRange 32 126
- class CRange (a :: k) where
- toRanges :: Proxy a -> [(Integer, Integer)]
- inRanges :: Integral i => i -> [(Integer, Integer)] -> Bool
- newtype BoundedList (a :: Type) (from :: Nat) (to :: Nat) = BoundedList [a]
- unBoundedList :: BoundedList a from to -> [a]
Documentation
type Range (i :: Type) (from :: Nat) (to :: Nat) = Ranges i '['(from, to)] #
Modifier for generating integral values within given inclusive range.
Range Int 0 42
will have arbitrary values of type Int
in range from
0 to 42 inclusive.
newtype Ranges :: Type -> [(Nat, Nat)] -> Type where #
Modifier for choosing arbitrarily from multiple ranges (first range is chosen uniformly, than value from this range is chosen uniformly).
For example, Ranges Int [(0,0), (10, 19)]
will with probability 1/2
generate 0
, and with probability 1/20
one of (10, 19) inclusive.
Instances
(Integral i, Arbitrary i, Random i, CRange ranges) => Arbitrary (Ranges i ranges) # | it would seem like the OVERLAPPABLE is redundant here, but GHC 8.2 has problem with Ranges Char instances otherwise |
CoArbitrary i => CoArbitrary (Ranges i r) # | |
Defined in Test.QuickCheck.Range Methods coarbitrary :: Ranges i r -> Gen b -> Gen b | |
Function i => Function (Ranges i r) # | |
Defined in Test.QuickCheck.Range | |
Show i => Show (Ranges i ranges) # | Show instance is transparent. |
NFData i => NFData (Ranges i ranges) # | |
Defined in Test.QuickCheck.Range | |
Eq i => Eq (Ranges i ranges) # | |
Ord i => Ord (Ranges i ranges) # | |
Defined in Test.QuickCheck.Range Methods compare :: Ranges i ranges -> Ranges i ranges -> Ordering (<) :: Ranges i ranges -> Ranges i ranges -> Bool (<=) :: Ranges i ranges -> Ranges i ranges -> Bool (>) :: Ranges i ranges -> Ranges i ranges -> Bool (>=) :: Ranges i ranges -> Ranges i ranges -> Bool max :: Ranges i ranges -> Ranges i ranges -> Ranges i ranges min :: Ranges i ranges -> Ranges i ranges -> Ranges i ranges |
newtype CharRanges ranges #
Instances
CRange ranges => Arbitrary (CharRanges ranges) # | |
Defined in Test.QuickCheck.Range | |
CoArbitrary (CharRanges r) # | |
Defined in Test.QuickCheck.Range Methods coarbitrary :: CharRanges r -> Gen b -> Gen b | |
Function (CharRanges r) # | |
Defined in Test.QuickCheck.Range Methods function :: (CharRanges r -> b) -> CharRanges r :-> b | |
Show (CharRanges ranges) # | |
Defined in Test.QuickCheck.Range Methods showsPrec :: Int -> CharRanges ranges -> ShowS show :: CharRanges ranges -> String showList :: [CharRanges ranges] -> ShowS | |
NFData (CharRanges ranges) # | |
Defined in Test.QuickCheck.Range Methods rnf :: CharRanges ranges -> () | |
Eq (CharRanges ranges) # | |
Defined in Test.QuickCheck.Range Methods (==) :: CharRanges ranges -> CharRanges ranges -> Bool (/=) :: CharRanges ranges -> CharRanges ranges -> Bool | |
Ord (CharRanges ranges) # | |
Defined in Test.QuickCheck.Range Methods compare :: CharRanges ranges -> CharRanges ranges -> Ordering (<) :: CharRanges ranges -> CharRanges ranges -> Bool (<=) :: CharRanges ranges -> CharRanges ranges -> Bool (>) :: CharRanges ranges -> CharRanges ranges -> Bool (>=) :: CharRanges ranges -> CharRanges ranges -> Bool max :: CharRanges ranges -> CharRanges ranges -> CharRanges ranges min :: CharRanges ranges -> CharRanges ranges -> CharRanges ranges |
unCharRange :: CharRanges ranges -> Char #
charRangeToRange :: CharRanges ranges -> Ranges Char ranges #
type CharRange (from :: Nat) (to :: Nat) = CharRanges '['(from, to)] #
type AsciiPrintableRange = CharRange 32 126 #
Convert compile time type ranges to runtime values.
Instances
CRange ('[] :: [k]) # | |
Defined in Test.QuickCheck.Range | |
(CRange head, CRange tail) => CRange (head ': tail :: [a]) # | |
Defined in Test.QuickCheck.Range | |
(KnownNat from, KnownNat to) => CRange ('(from, to) :: (Nat, Nat)) # | |
Defined in Test.QuickCheck.Range |
newtype BoundedList (a :: Type) (from :: Nat) (to :: Nat) #
Constructors
BoundedList [a] |
Instances
(Arbitrary a, KnownNat from, KnownNat to) => Arbitrary (BoundedList a from to) # | |
Defined in Test.QuickCheck.Range Methods arbitrary :: Gen (BoundedList a from to) shrink :: BoundedList a from to -> [BoundedList a from to] | |
CoArbitrary a => CoArbitrary (BoundedList a from to) # | |
Defined in Test.QuickCheck.Range Methods coarbitrary :: BoundedList a from to -> Gen b -> Gen b | |
Function a => Function (BoundedList a from to) # | |
Defined in Test.QuickCheck.Range Methods function :: (BoundedList a from to -> b) -> BoundedList a from to :-> b | |
Show a => Show (BoundedList a from to) # | |
Defined in Test.QuickCheck.Range Methods showsPrec :: Int -> BoundedList a from to -> ShowS show :: BoundedList a from to -> String showList :: [BoundedList a from to] -> ShowS | |
Eq a => Eq (BoundedList a from to) # | |
Defined in Test.QuickCheck.Range Methods (==) :: BoundedList a from to -> BoundedList a from to -> Bool (/=) :: BoundedList a from to -> BoundedList a from to -> Bool | |
Ord a => Ord (BoundedList a from to) # | |
Defined in Test.QuickCheck.Range Methods compare :: BoundedList a from to -> BoundedList a from to -> Ordering (<) :: BoundedList a from to -> BoundedList a from to -> Bool (<=) :: BoundedList a from to -> BoundedList a from to -> Bool (>) :: BoundedList a from to -> BoundedList a from to -> Bool (>=) :: BoundedList a from to -> BoundedList a from to -> Bool max :: BoundedList a from to -> BoundedList a from to -> BoundedList a from to min :: BoundedList a from to -> BoundedList a from to -> BoundedList a from to |
unBoundedList :: BoundedList a from to -> [a] #