Skip to content

Conversation

@drewctaylor
Copy link
Contributor

Fixes #401. Add fj.test.Gen.sequence(Validation<E, Gen>).

It should transform a validation for a generator into a generator of validations: if the given validation is a failure, the generator produces that failure value; if the given validation is a success, the generator produces success values.

public static <E, A> Gen<Validation<E, A>> sequence(final Validation<E, Gen<A>> gv) {
    return gen(i -> r -> gv.map(g -> g.gen(i, r)));
}

@tonymorris tonymorris merged commit d89c845 into functionaljava:series/4.x Jul 21, 2020
@tonymorris
Copy link
Contributor

Cheers mate.

@drewctaylor drewctaylor deleted the functionaljava-401 branch July 24, 2020 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants