Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delay and similar utils to the Fx continuations #1277

Closed
raulraja opened this issue Feb 1, 2019 · 2 comments
Closed

Add delay and similar utils to the Fx continuations #1277

raulraja opened this issue Feb 1, 2019 · 2 comments

Comments

@raulraja
Copy link
Member

raulraja commented Feb 1, 2019

Currently using delay from the coroutines lib in a Fx continuation results in a runtime exception:

fx {
  !effect {
    otherGreetings()
    greetings()
  }
}

private suspend fun greetings() {
  delay(100)
  println("Hello!")
}

private suspend fun otherGreetings() {
  delay(200)
  println("Hi!")
}
Caused by: kotlin.UninitializedPropertyAccessException: lateinit property returnedMonad has not been initialized
        at arrow.typeclasses.MonadContinuation.getReturnedMonad(MonadContinuations.kt:49)
        at arrow.effects.typeclasses.MonadDeferCancellableContinuation.returnedMonad(MonadDeferCancellableContinuations.kt:32)
        at arrow.effects.typeclasses.Concurrent$DefaultImpls.bindingConcurrent(Concurrent.kt:710)
        at arrow.effects.extensions.IOConcurrent$DefaultImpls.bindingConcurrent(Unknown Source:8)
        at arrow.effects.extensions.io.concurrent.IOConcurrentKt$concurrent$1.bindingConcurrent(IOConcurrent.kt:443)
        at arrow.effects.typeclasses.suspended.concurrent.Fx$DefaultImpls.fx(Fx.kt:12)
        at arrow.effects.extensions.IOFx$DefaultImpls.fx(Unknown Source:8)
        at arrow.effects.extensions.io.fx.IOFxKt$fx$1.fx(IOFx.kt:49)
        at arrow.effects.extensions.io.fx.IOFxKt.fx(IOFx.kt:25)

Originally reported in gitter https://gitter.im/arrow-kt/Lobby?at=5c52d4998aa5ca5abf5f23e5

@pakoito
Copy link
Member

pakoito commented Feb 1, 2019

delay needs to be lifted like everyone else, else it advances the coroutine pointer and this happens :D

raulraja added a commit that referenced this issue Feb 27, 2019
…pes that are unable to suspend effects

- Reencodes Ank in terms of `fx`
raulraja added a commit that referenced this issue Feb 27, 2019
…pes that are unable to suspend effects (#1319)

- Reencodes Ank in terms of `fx`
@nomisRev
Copy link
Member

nomisRev commented May 9, 2019

I discussed this with @pakoito and we should introduce these operators in Async and Concurrent. Without -and with cancellation respectively.

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

No branches or pull requests

3 participants