Suppose, I have types like
data D = A | B String | C String
data TestIt m = TestIt {
x :: m Int
, y :: Int -> m D
}
and I am writing SmallCheck test, so I need Serial
instance on TestIt
:
instance Monad m => Serial m (TestIt m) where
series = TestIt <$> (pure <$> series) <~> xxx
How to write this xxx
? I understand that it maybe needs CoSerial
like function, but 1) I am not sure 2) I don't know how to write it. When I see CoSerial
documentation, I see that my CoSerial
will have Int
and not D
in its definition:
instance (CoSerial m a) => CoSerial m (Int a) where
coseries rs = ???
so I can not get idea of CoSerial
s and how to use them to make Serial
for Int -> m D
.
Also I want to have dependent serial for y
field. I mean if x
has sample 0 then serial of y
should get 0
as argument. Is it possible?