1
import Bow
2
import SwiftCheck
3

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

6
extension EitherK: Arbitrary where F: ArbitraryK, G: ArbitraryK, A: Arbitrary {
7 0
    public static var arbitrary: Gen<EitherK<F, G, A>> {
8 0
        return Gen.from(EitherKPartial.generate >>> EitherK.fix)
9
    }
10
}
11

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

14
extension EitherKPartial: ArbitraryK where F: ArbitraryK, G: ArbitraryK {
15 1
    public static func generate<A: Arbitrary>() -> Kind<EitherKPartial<F, G>, A> {
16 1
        let left = EitherK<F, G, A>(F.generate())
17 1
        let right = EitherK<F, G, A>(G.generate())
18 1
        return Gen.one(of: [Gen.pure(left), Gen.pure(right)]).generate
19
    }
20
}

Read our documentation on viewing source code .

Loading