git.iko.soy/typeable/generic-arbitrary
on master help sign in
typos
commit48761743bcccd8e980a3985fc9fe495bc089e2dd authorAleksey Uymanov <s9gf4ult@gmail.com> dateFri 12 Aug 2022, 11:18 (4 years ago) parenta3f58a4
3 files changed+22−18
README.md+20−17 generic-arbitrary.cabal+1 src/Test/QuickCheck/Arbitrary/Generic.hs+1−1
README.md+20−17
@@ -93,7 +93,7 @@ there is a problem with mutually recursive types.
9393
9494# Type parameters
9595
96−Now lets see an example of datatype with parameters
96+Now let's see an example of datatype with parameters
9797
9898``` haskell
9999data A a = A a
@@ -108,25 +108,28 @@ instance (Arbitrary a) => Arbitrary (A a) where
108108
109109It should work from first glance, but when compile it will throw an error:
110110
111−> • Could not deduce (Test.QuickCheck.Arbitrary.Generic.GArbitrary
112−> (A a)
113−> (GHC.Generics.D1
114−> ('GHC.Generics.MetaData "A" "ParametersTest" "main" 'False)
115−> (GHC.Generics.C1
116−> ('GHC.Generics.MetaCons "A" 'GHC.Generics.PrefixI 'False)
117−> (GHC.Generics.S1
118−> ('GHC.Generics.MetaSel
119−> 'Nothing
120−> 'GHC.Generics.NoSourceUnpackedness
121−> 'GHC.Generics.NoSourceStrictness
122−> 'GHC.Generics.DecidedLazy)
123−> (GHC.Generics.Rec0 a))))
124−> (TypesDiffer (A a) a))
125−> arising from a use of ‘genericArbitrary’
111+```
112+• Could not deduce (Test.QuickCheck.Arbitrary.Generic.GArbitrary
113+ (A a)
114+ (GHC.Generics.D1
115+ ('GHC.Generics.MetaData "A" "ParametersTest" "main" 'False)
116+ (GHC.Generics.C1
117+ ('GHC.Generics.MetaCons "A" 'GHC.Generics.PrefixI 'False)
118+ (GHC.Generics.S1
119+ ('GHC.Generics.MetaSel
120+ 'Nothing
121+ 'GHC.Generics.NoSourceUnpackedness
122+ 'GHC.Generics.NoSourceStrictness
123+ 'GHC.Generics.DecidedLazy)
124+ (GHC.Generics.Rec0 a))))
125+ (TypesDiffer (A a) a))
126+ arising from a use of ‘genericArbitrary’
127+```
126128
127129Here the `TypesDiffer` is a type familty dealing with recursive types and
128130helping us to eliminate inproper instances. To convince the compiller, that the
129−`a` parameter is not an `A a` we must fix the instance with additional constraint
131+`a` parameter is not an `A a` we must fix the instance with additional
132+constraint `Arg (A a) a`
130133
131134``` haskell
132135instance (Arg (A a) a, Arbitrary a) => Arbitrary (A a) where
generic-arbitrary.cabal+1
@@ -15,6 +15,7 @@ homepage: http://github.com/typeable/generic-arbitrary#readme
1515category: Generic
1616build-type: Simple
1717extra-source-files: CHANGELOG.md
18+ , README.md
1819cabal-version: 1.22
1920tested-with: GHC == 8.10.7
2021 , GHC == 9.0.2
src/Test/QuickCheck/Arbitrary/Generic.hs+1−1
@@ -127,7 +127,6 @@ Now everything compiles and works as expected.
127127module Test.QuickCheck.Arbitrary.Generic
128128 ( -- * Main
129129 genericArbitrary
130− , genericShrink
131130#if MIN_VERSION_QuickCheck(2, 14, 0)
132131 , GenericArbitrary(..)
133132#endif
@@ -143,6 +142,7 @@ module Test.QuickCheck.Arbitrary.Generic
143142 , SumLen
144143 -- * Reexports
145144 , Arbitrary(..)
145+ , genericShrink
146146 ) where
147147
148148import Control.Applicative