@@ -15,14 +15,14 @@ import Prelude
1515
1616import Control.Monad.Gen.Class (chooseBool )
1717import Control.Monad.Gen.Common as MGC
18- import Control.Monad.ST ( pureST )
18+ import Control.Monad.ST as ST
1919import Data.Array.NonEmpty (NonEmptyArray )
2020import Data.Array.NonEmpty as NEA
2121import Data.Array.ST (pushSTArray , unsafeFreeze , unsafeThaw )
2222import Data.Char (toCharCode , fromCharCode )
2323import Data.Either (Either (..))
2424import Data.Foldable (foldl )
25- import Data.Generic.Rep (class Generic , to , from , NoArguments (..), Sum (..), Product (..), Constructor (..), Argument (..), Rec (..), Field (..) )
25+ import Data.Generic.Rep (class Generic , to , from , NoArguments (..), Sum (..), Product (..), Constructor (..), Argument (..))
2626import Data.Identity (Identity (..))
2727import Data.Int (toNumber )
2828import Data.Lazy (Lazy , defer , force )
@@ -31,16 +31,17 @@ import Data.List.NonEmpty (NonEmptyList(..))
3131import Data.Maybe (Maybe (..), fromJust )
3232import Data.Newtype (wrap )
3333import Data.NonEmpty (NonEmpty (..), (:|))
34- import Data.Record ( insert )
34+ import Data.Record as Record
3535import Data.String (charCodeAt , fromCharArray , split )
3636import Data.String.NonEmpty (NonEmptyString )
3737import Data.String.NonEmpty as NES
3838import Data.Symbol (class IsSymbol , SProxy (..))
3939import Data.Tuple (Tuple (..))
4040import Partial.Unsafe (unsafePartial )
41+ import Prim.Row as Row
42+ import Prim.RowList as RL
4143import Test.QuickCheck.Gen (Gen , arrayOf , chooseInt , elements , listOf , oneOf , perturbGen , repeatable , sized , uniform )
42- import Type.Prelude (class RowToList )
43- import Type.Row (kind RowList , class RowLacks , Nil , Cons , RLProxy (..))
44+ import Type.Data.RowList (RLProxy (..))
4445
4546-- | The `Arbitrary` class represents those types whose values can be
4647-- | _randomly-generated_.
@@ -117,13 +118,13 @@ instance arbArray :: Arbitrary a => Arbitrary (Array a) where
117118 arbitrary = arrayOf arbitrary
118119
119120instance coarbArray :: Coarbitrary a => Coarbitrary (Array a ) where
120- coarbitrary = foldl (\f x -> f <<< coarbitrary x) id
121+ coarbitrary = foldl (\f x -> f <<< coarbitrary x) identity
121122
122123instance arbNonEmptyArray :: Arbitrary a => Arbitrary (NonEmptyArray a ) where
123124 arbitrary = do
124125 x <- arbitrary
125126 xs <- arbitrary
126- pure $ unsafePartial fromJust $ NEA .fromArray $ pureST do
127+ pure $ unsafePartial fromJust $ NEA .fromArray $ ST .run do
127128 mxs <- unsafeThaw xs
128129 _ <- pushSTArray mxs x
129130 unsafeFreeze mxs
@@ -163,7 +164,7 @@ instance arbitraryList :: Arbitrary a => Arbitrary (List a) where
163164 arbitrary = sized \n -> chooseInt zero n >>= flip listOf arbitrary
164165
165166instance coarbList :: Coarbitrary a => Coarbitrary (List a ) where
166- coarbitrary = foldl (\f x -> f <<< coarbitrary x) id
167+ coarbitrary = foldl (\f x -> f <<< coarbitrary x) identity
167168
168169instance arbitraryIdentity :: Arbitrary a => Arbitrary (Identity a ) where
169170 arbitrary = Identity <$> arbitrary
@@ -193,7 +194,7 @@ instance arbitraryNoArguments :: Arbitrary NoArguments where
193194 arbitrary = pure NoArguments
194195
195196instance coarbitraryNoArguments :: Coarbitrary NoArguments where
196- coarbitrary NoArguments = id
197+ coarbitrary NoArguments = identity
197198
198199-- | To be able to evenly distribute over chains of Sum types we build up
199200-- | a collection of generators and choose between. Each right component
@@ -232,18 +233,6 @@ instance arbitraryArgument :: Arbitrary a => Arbitrary (Argument a) where
232233instance coarbitraryArgument :: Coarbitrary a => Coarbitrary (Argument a ) where
233234 coarbitrary (Argument a) = coarbitrary a
234235
235- instance arbitraryRec :: Arbitrary a => Arbitrary (Rec a ) where
236- arbitrary = Rec <$> arbitrary
237-
238- instance coarbitraryRec :: Coarbitrary a => Coarbitrary (Rec a ) where
239- coarbitrary (Rec a) = coarbitrary a
240-
241- instance arbitraryField :: Arbitrary a => Arbitrary (Field s a ) where
242- arbitrary = Field <$> arbitrary
243-
244- instance coarbitraryField :: Coarbitrary a => Coarbitrary (Field s a ) where
245- coarbitrary (Field a) = coarbitrary a
246-
247236-- | A `Generic` implementation of the `arbitrary` member from the `Arbitrary` type class.
248237genericArbitrary :: forall a rep . Generic a rep => Arbitrary rep => Gen a
249238genericArbitrary = to <$> (arbitrary :: Gen rep )
@@ -253,30 +242,27 @@ genericCoarbitrary :: forall a rep. Generic a rep => Coarbitrary rep => a -> Gen
253242genericCoarbitrary x g = to <$> coarbitrary (from x) (from <$> g)
254243
255244-- | A helper typeclass to implement `Arbitrary` for records.
256- class ArbitraryRowList
257- (list :: RowList )
258- (row :: # Type )
259- | list -> row where
245+ class ArbitraryRowList list row | list -> row where
260246 arbitraryRecord :: RLProxy list -> Gen (Record row )
261247
262- instance arbitraryRowListNil :: ArbitraryRowList Nil () where
248+ instance arbitraryRowListNil :: ArbitraryRowList RL. Nil () where
263249 arbitraryRecord _ = pure {}
264250
265251instance arbitraryRowListCons ::
266252 ( Arbitrary a
267253 , ArbitraryRowList listRest rowRest
268- , RowLacks key rowRest
269- , RowCons key a rowRest rowFull
270- , RowToList rowFull (Cons key a listRest )
254+ , Row.Lacks key rowRest
255+ , Row.Cons key a rowRest rowFull
256+ , RL. RowToList rowFull (RL. Cons key a listRest )
271257 , IsSymbol key
272- ) => ArbitraryRowList (Cons key a listRest ) rowFull where
258+ ) => ArbitraryRowList (RL. Cons key a listRest ) rowFull where
273259 arbitraryRecord _ = do
274260 value <- arbitrary
275261 previous <- arbitraryRecord (RLProxy :: RLProxy listRest )
276- pure $ insert (SProxy :: SProxy key ) value previous
262+ pure $ Record . insert (SProxy :: SProxy key ) value previous
277263
278264instance arbitraryRecordInstance ::
279- ( RowToList row list
265+ ( RL. RowToList row list
280266 , ArbitraryRowList list row
281267 ) => Arbitrary (Record row ) where
282268 arbitrary = arbitraryRecord (RLProxy :: RLProxy list )
0 commit comments