@@ -4,11 +4,14 @@ import Prelude
44
55import Data.Char (toCharCode , fromCharCode )
66import 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 (..))
712import Data.Maybe (Maybe (..))
813import Data.String (charCodeAt , fromCharArray , split )
914import Data.Tuple (Tuple (..))
10- import Data.Int (fromNumber , toNumber )
11- import Data.Foldable (foldl )
1215import Test.QuickCheck.Gen
1316
1417-- | 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
115118instance coarbEither :: (Coarbitrary a , Coarbitrary b ) => Coarbitrary (Either a b ) where
116119 coarbitrary (Left a) = coarbitrary a
117120 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