Git Product home page Git Product logo

Comments (5)

johnmcclean avatar johnmcclean commented on June 7, 2024

You can use splitBy, which is present on ImmutableList, ImmutableQueue, ImmutableSortedSet and ReactiveSeq to do this.

But we should add a static convenience method on Either also.

from cyclops.

ayush-finix avatar ayush-finix commented on June 7, 2024

My only issue with split by is that the signature doesn't quite unpack the datatypes (which is totally reasonable/expected for a generic split by).
Seq<Either<A, B>>.splitBy -> Tuple2<Seq<Either<A, B>>, Seq<Either<A, B>>>
instead of
Seq<Either<A, B>>.eitherSplitBy->Tuple2<Seq<A>, Seq<B>>
Right now, I'm just manually accumulating, which is a pretty simple, although, really verbose workaround (and I'm not sure of its streaming vs loading into memory ramifications for larger use cases).

It would also be useful as a static method on try directly as well.

from cyclops.

ayush-finix avatar ayush-finix commented on June 7, 2024

As a related question, is there a pattern for not only splitting the response try/either but also keeping the original request with it?

something where
function: request -> Try<Response, Exception>;
List requests.map(this::function)->??????->Tuple2<List<Tuple2<Request, Response>>, List<Tuple2<Request, Exception>>>
happens?

Right now I'm just manually passing along the request everywhere.

from cyclops.

johnmcclean avatar johnmcclean commented on June 7, 2024

Added partitionEithers, lefts, rights as static methods to the Either class.

from cyclops.

johnmcclean avatar johnmcclean commented on June 7, 2024

Merged.

from cyclops.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.