@@ -4,11 +4,14 @@ import Prelude
4
4
5
5
import Data.Char (toCharCode , fromCharCode )
6
6
import Data.Either (Either (..))
7
+ import Data.Foldable (foldl )
8
+ import Data.Identity (Identity (..))
9
+ import Data.Int (fromNumber , toNumber )
10
+ import Data.Lazy (Lazy (), defer , force )
11
+ import Data.List (List (..))
7
12
import Data.Maybe (Maybe (..))
8
13
import Data.String (charCodeAt , fromCharArray , split )
9
14
import Data.Tuple (Tuple (..))
10
- import Data.Int (fromNumber , toNumber )
11
- import Data.Foldable (foldl )
12
15
import Test.QuickCheck.Gen
13
16
14
17
-- | The `Arbitrary` class represents those types whose values can be
@@ -115,3 +118,21 @@ instance arbEither :: (Arbitrary a, Arbitrary b) => Arbitrary (Either a b) where
115
118
instance coarbEither :: (Coarbitrary a , Coarbitrary b ) => Coarbitrary (Either a b ) where
116
119
coarbitrary (Left a) = coarbitrary a
117
120
coarbitrary (Right b) = coarbitrary b
121
+
122
+ instance arbitraryList :: (Arbitrary a ) => Arbitrary (List a ) where
123
+ arbitrary = sized \n -> chooseInt zero n >>= flip listOf arbitrary
124
+
125
+ instance coarbList :: (Coarbitrary a ) => Coarbitrary (List a ) where
126
+ coarbitrary = foldl (\f x -> f <<< coarbitrary x) id
127
+
128
+ instance arbitraryIdentity :: (Arbitrary a ) => Arbitrary (Identity a ) where
129
+ arbitrary = Identity <$> arbitrary
130
+
131
+ instance coarbIdentity :: (Coarbitrary a ) => Coarbitrary (Identity a ) where
132
+ coarbitrary (Identity a) = coarbitrary a
133
+
134
+ instance arbitraryLazy :: (Arbitrary a ) => Arbitrary (Lazy a ) where
135
+ arbitrary = arbitrary >>= pure <<< defer <<< const
136
+
137
+ instance coarbLazy :: (Coarbitrary a ) => Coarbitrary (Lazy a ) where
138
+ coarbitrary a = coarbitrary (force a)
0 commit comments