@@ -18,54 +18,54 @@ import Test.QuickCheck.Gen
1818class Arbitrary t where
1919 arbitrary :: Gen t
2020
21- -- | The `CoArbitrary ` class represents types which appear on the left of
21+ -- | The `Coarbitrary ` class represents types which appear on the left of
2222-- | an `Arbitrary` function arrow.
2323-- |
2424-- | To construct an `Arbitrary` instance for the type `a -> b`, we need to
2525-- | use the input of type `a` to _perturb_ a random generator for `b`. This
2626-- | is the role of the `coarbitrary` function.
2727-- |
28- -- | `CoArbitrary ` instances can be written using the `perturbGen` function.
29- class CoArbitrary t where
28+ -- | `Coarbitrary ` instances can be written using the `perturbGen` function.
29+ class Coarbitrary t where
3030 coarbitrary :: forall r . t -> Gen r -> Gen r
3131
3232instance arbBoolean :: Arbitrary Boolean where
3333 arbitrary = do
3434 n <- uniform
3535 return $ (n * 2 ) < 1
3636
37- instance coarbBoolean :: CoArbitrary Boolean where
37+ instance coarbBoolean :: Coarbitrary Boolean where
3838 coarbitrary true = perturbGen 1
3939 coarbitrary false = perturbGen 2
4040
4141instance arbNumber :: Arbitrary Number where
4242 arbitrary = uniform
4343
44- instance coarbNumber :: CoArbitrary Number where
44+ instance coarbNumber :: Coarbitrary Number where
4545 coarbitrary = perturbGen
4646
4747instance arbInt :: Arbitrary Int where
4848 arbitrary = chooseInt (fromNumber (-1000000 )) (fromNumber 1000000 )
4949
50- instance coarbInt :: CoArbitrary Int where
50+ instance coarbInt :: Coarbitrary Int where
5151 coarbitrary = perturbGen <<< toNumber
5252
5353instance arbString :: Arbitrary String where
5454 arbitrary = fromCharArray <$> arbitrary
5555
56- instance coarbString :: CoArbitrary String where
56+ instance coarbString :: Coarbitrary String where
5757 coarbitrary s = coarbitrary $ (charCodeAt zero <$> split " " s)
5858
5959instance arbChar :: Arbitrary Char where
6060 arbitrary = fromCharCode <<< fromNumber <<< (* 65535 ) <$> uniform
6161
62- instance coarbChar :: CoArbitrary Char where
62+ instance coarbChar :: Coarbitrary Char where
6363 coarbitrary c = coarbitrary $ toCharCode c
6464
6565instance arbUnit :: Arbitrary Unit where
6666 arbitrary = return unit
6767
68- instance coarbUnit :: CoArbitrary Unit where
68+ instance coarbUnit :: Coarbitrary Unit where
6969 coarbitrary _ = perturbGen 1
7070
7171instance arbOrdering :: Arbitrary Ordering where
@@ -76,7 +76,7 @@ instance arbOrdering :: Arbitrary Ordering where
7676 2 -> EQ
7777 3 -> GT
7878
79- instance coarbOrdering :: CoArbitrary Ordering where
79+ instance coarbOrdering :: Coarbitrary Ordering where
8080 coarbitrary LT = perturbGen 1
8181 coarbitrary EQ = perturbGen 2
8282 coarbitrary GT = perturbGen 3
@@ -89,30 +89,30 @@ instance arbArray :: (Arbitrary a) => Arbitrary [a] where
8989 as <- arbitrary
9090 return (a : as)
9191
92- instance coarbArray :: (CoArbitrary a ) => CoArbitrary [a ] where
92+ instance coarbArray :: (Coarbitrary a ) => Coarbitrary [a ] where
9393 coarbitrary [] = id
9494 coarbitrary (x : xs) = coarbitrary xs <<< coarbitrary x
9595
96- instance arbFunction :: (CoArbitrary a , Arbitrary b ) => Arbitrary (a -> b ) where
96+ instance arbFunction :: (Coarbitrary a , Arbitrary b ) => Arbitrary (a -> b ) where
9797 arbitrary = repeatable (\a -> coarbitrary a arbitrary)
9898
99- instance coarbFunction :: (Arbitrary a , CoArbitrary b ) => CoArbitrary (a -> b ) where
99+ instance coarbFunction :: (Arbitrary a , Coarbitrary b ) => Coarbitrary (a -> b ) where
100100 coarbitrary f gen = do
101101 xs <- arbitrary
102102 coarbitrary (map f xs) gen
103103
104104instance arbTuple :: (Arbitrary a , Arbitrary b ) => Arbitrary (Tuple a b ) where
105105 arbitrary = Tuple <$> arbitrary <*> arbitrary
106106
107- instance coarbTuple :: (CoArbitrary a , CoArbitrary b ) => CoArbitrary (Tuple a b ) where
107+ instance coarbTuple :: (Coarbitrary a , Coarbitrary b ) => Coarbitrary (Tuple a b ) where
108108 coarbitrary (Tuple a b) = coarbitrary a >>> coarbitrary b
109109
110110instance arbMaybe :: (Arbitrary a ) => Arbitrary (Maybe a ) where
111111 arbitrary = do
112112 b <- arbitrary
113113 if b then pure Nothing else Just <$> arbitrary
114114
115- instance coarbMaybe :: (CoArbitrary a ) => CoArbitrary (Maybe a ) where
115+ instance coarbMaybe :: (Coarbitrary a ) => Coarbitrary (Maybe a ) where
116116 coarbitrary Nothing = perturbGen 1
117117 coarbitrary (Just a) = coarbitrary a
118118
@@ -121,6 +121,6 @@ instance arbEither :: (Arbitrary a, Arbitrary b) => Arbitrary (Either a b) where
121121 b <- arbitrary
122122 if b then Left <$> arbitrary else Right <$> arbitrary
123123
124- instance coarbEither :: (CoArbitrary a , CoArbitrary b ) => CoArbitrary (Either a b ) where
124+ instance coarbEither :: (Coarbitrary a , Coarbitrary b ) => Coarbitrary (Either a b ) where
125125 coarbitrary (Left a) = coarbitrary a
126126 coarbitrary (Right b) = coarbitrary b
0 commit comments