Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Support suspend in fx #116

Closed
4 of 6 tasks
nomisRev opened this issue May 21, 2020 · 2 comments · Fixed by #112
Closed
4 of 6 tasks

Support suspend in fx #116

nomisRev opened this issue May 21, 2020 · 2 comments · Fixed by #112
Assignees
Milestone

Comments

@nomisRev
Copy link
Member

nomisRev commented May 21, 2020

Currently we don't support suspend for fx blocks.

This prevents mixing suspend with fx, which would be the most Kotlin idiomatic.

import arrow.core.Either
import arrow.core.extensions.fx

data class User(val name: String)
object DomainError

suspend fun fetchDataFromNetwork(id: Int): Either<DomainError, User> = TODO()

suspend fun getUser(id: Int) : Either<DomainError, User> =
  Either.fx<DomainError, User> {
    // Restricted suspending functions can only invoke member or extension suspending functions on their restricted coroutine scope
    !fetchDataFromNetwork(id) 
  }

In #112, this change was implemented for Either, and it can be implemented for all other data types in the same way.

This needs to happen for all data types that are not marked for deprecation in #114.

  • Either
  • Validated
  • NonEmptyList
  • Eval
  • Const
  • Ior
@nomisRev nomisRev added this to the 0.11.0 milestone May 21, 2020
@aballano aballano self-assigned this May 27, 2020
@aballano aballano linked a pull request May 27, 2020 that will close this issue
@aballano
Copy link
Member

All of NonEmptyList, ListK, SequenceK and Ior would need a rework on the current system to use flatmap (or something similar) as otherwise we cannot achieve the same operation with the current architecture.

@aballano
Copy link
Member

aballano commented Jul 1, 2020

Leftover datatypes will be tackled in #171

@aballano aballano closed this as completed Jul 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants