Skip to content

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

Description

@drewctaylor

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)));
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions