1
import Bow
2
import SwiftCheck
3

4
// MARK: Generator for Property-based Testing
5

6
extension StateT: Arbitrary where F: ArbitraryK & Applicative, S: Arbitrary, A: Arbitrary {
7 0
    public static var arbitrary: Gen<StateT<F, S, A>> {
8 0
        return Gen.from(StateTPartial.generate >>> StateT.fix)
9
    }
10
}
11

12
// MARK: Instance of `ArbitraryK` for `StateT`
13

14
extension StateTPartial: ArbitraryK where F: ArbitraryK & Applicative, S: Arbitrary {
15 1
    public static func generate<A: Arbitrary>() -> Kind<StateTPartial<F, S>, A> {
16 1
        let a = A.arbitrary.generate
17 1
        let f: (S) -> Kind<F, (S, A)> = { s in F.pure((s, a)) }
18 1
        return StateT(F.pure(f))
19
    }
20
}

Read our documentation on viewing source code .

Loading