Skip to content

Commit 0744e14

Browse files
committed
arrange docs
1 parent a957f17 commit 0744e14

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

src/Test/QuickCheck/Arbitrary/Generic.hs

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,26 @@ Now everything compiles and works as expected.
125125
-}
126126

127127
module Test.QuickCheck.Arbitrary.Generic
128-
( Arbitrary(..)
128+
( -- * Main
129+
genericArbitrary
130+
, genericShrink
129131
#if MIN_VERSION_QuickCheck(2, 14, 0)
130132
, GenericArbitrary(..)
131133
#endif
132134
, Arg
133-
, TypesDiffer
134-
, AllFieldsFinal
135+
-- * Internal
136+
, GArbitrary
137+
, FiniteSum
138+
, FiniteSumElem
135139
, Finite
140+
, AllFieldsFinal
141+
, TypesDiffer
136142
, ArgumentsCount
137143
, SumLen
138-
, genericArbitrary
139-
, genericShrink
144+
-- * Reexports
145+
, Arbitrary(..)
140146
) where
141147

142-
143-
144-
145148
import Control.Applicative
146149
import Data.Coerce (coerce)
147150
import Data.Proxy
@@ -155,6 +158,16 @@ import Test.QuickCheck.Arbitrary (GSubterms, RecursivelyShrink)
155158

156159

157160
-- | Newtype for @DerivingVia@
161+
--
162+
-- Usage:
163+
--
164+
-- @
165+
-- data Foo = Foo
166+
-- { _fooX :: X
167+
-- , _fooY :: Y
168+
-- } deriving (Generic)
169+
-- deriving (Arbitrary) via GenericArbitrary Foo
170+
-- @
158171
newtype GenericArbitrary a = GenericArbitrary { unGenericArbitrary :: a }
159172
deriving (Show, Eq)
160173

@@ -168,6 +181,18 @@ instance
168181
shrink = coerce (genericShrink :: a -> [a])
169182
#endif
170183

184+
-- | Constraint helper for types with parameters
185+
--
186+
-- Usage:
187+
--
188+
-- @
189+
-- data A a = A a
190+
-- deriving (Generic)
191+
-- instance (Arg (A a) a, Arbitrary a) => Arbitrary (A a) where
192+
-- arbitrary = genericArbitrary
193+
-- shrink = genericShrink
194+
-- @
195+
171196
type Arg self field = (TypesDiffer self field ~ 'True)
172197

173198
type family TypesDiffer a b where

0 commit comments

Comments
 (0)