Giter VIP home page Giter VIP logo

Comments (7)

pakoito avatar pakoito commented on June 10, 2024 1

FOr 0.10, using fold

getConfiguration().fold(
  { /* error handling */}, 
  { getMovies(it) }
)

In 0.11, use IO<E, A>, which should come with them: arrow-kt/arrow-fx#145

from arrow-core.

raulraja avatar raulraja commented on June 10, 2024

This is only possible exploiting the inline trick in fold since any of those functions would need to have a continuation and map, flatMap, etc can capture the lambda context which would escape the continuation.

from arrow-core.

pakoito avatar pakoito commented on June 10, 2024

Not necessarily fold, just using when works too. It cannot be part of the regular hierarchy because some Functors are not like that, i.e. Function1

from arrow-core.

aballano avatar aballano commented on June 10, 2024

If we would like to include this as part of Async then fine for me, but otherwise I would raise a "What would be the benefit for devs regarding this?" Since I'm unsure because right now I have troubles explaining the Either.catch to myself or how to use it properly, despite the fact that BIO will have this kind of API already.

from arrow-core.

raulraja avatar raulraja commented on June 10, 2024

Async already has this https://github.com/arrow-kt/arrow-fx/blob/043c0eccc7f3748fcbf469ad77c326048ad02cb3/arrow-fx/src/main/kotlin/arrow/fx/typeclasses/Async.kt#L343 effectMap

from arrow-core.

lukaszkalnik avatar lukaszkalnik commented on June 10, 2024

How can I currently in the simplest way chain suspending functions returning Either?

suspend fun getConfiguration(): Either<Exception, Config>
suspend fun getMovies(config: Config): Either<Exception, List<Movie>>

GlobalScope.launch {
    getConfiguration()
        .flatMap { config -> getMovies(config) }
        .fold { /* ... */ }
}

from arrow-core.

aballano avatar aballano commented on June 10, 2024

AFAIK we can use crossinline to restrict non-local returns, so this shouldn't be a problem. Closing in favour of #115

from arrow-core.

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.