@@ -35,11 +35,11 @@ import qualified Data.String.Unsafe as SU
3535
3636import Test.QuickCheck.Gen
3737
38- -- | The `Arbitrary` class represents those types whose values can be
38+ -- | The `Arbitrary` class represents those types whose values can be
3939-- | _randomly-generated_.
40- -- |
40+ -- |
4141-- | `arbitrary` uses the `Gen` monad to express a random generator for
42- -- | the type `t`. Combinators in the `Test.QuickCheck.Gen`
42+ -- | the type `t`. Combinators in the `Test.QuickCheck.Gen`
4343-- | module can be used to construct random generators.
4444class Arbitrary t where
4545 arbitrary :: Gen t
@@ -100,7 +100,26 @@ instance arbString :: Arbitrary String where
100100instance coarbString :: CoArbitrary String where
101101 coarbitrary s = coarbitrary $ (S .charCodeAt 0 <$> S .split " " s)
102102
103- -- | A newtype for `String` whose `Arbitrary` instance generated random
103+ instance arbUnit :: Arbitrary Unit where
104+ arbitrary = return unit
105+
106+ instance coarbUnit :: CoArbitrary Unit where
107+ coarbitrary _ = perturbGen 1
108+
109+ instance arbOrdering :: Arbitrary Ordering where
110+ arbitrary = do
111+ n <- (3 *) <$> uniform
112+ return $ case n of
113+ _ | n < 1 -> LT
114+ | n < 2 -> EQ
115+ | otherwise -> GT
116+
117+ instance coarbOrdering :: CoArbitrary Ordering where
118+ coarbitrary LT = perturbGen 1
119+ coarbitrary EQ = perturbGen 2
120+ coarbitrary GT = perturbGen 3
121+
122+ -- | A newtype for `String` whose `Arbitrary` instance generated random
104123-- | alphanumeric strings.
105124newtype AlphaNumString = AlphaNumString String
106125
0 commit comments