https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
arrow
  • s

    Satyam Agarwal

    02/15/2020, 1:09 PM
    Hei, does arrow have support for
    java.util.concurrent.Future
    ?/ Can I convert java’s future to IO ? I know I can alway do
    IO.invoke {  sendFuture().get() }
    . I am not exactly able to explain, what I want, But I am looking for something like coroutines/reactor support in arrow-fx, for java’s futures
    p
    • 2
    • 3
  • m

    melatonina

    02/17/2020, 9:46 AM
    Hello. I have a sequence of Option<T>. How do I get the first non-None item or None if there is none? I can do that by mapping the Option<T> to T?, working with the nullable and remapping it to Option<T> at the end, of course. What is the Λrrow idiom for this operation?
    s
    j
    • 3
    • 19
  • c

    CLOVIS

    02/17/2020, 10:50 AM
    In actual programming, you can always define
    fold
    on any Functor, but not all operations can be called on it (there needs to be a default value). So it sounds like
    fold
    is defined neither on a category nor on a morphism but on the pair of both of them?
    r
    • 2
    • 9
  • r

    raulraja

    02/17/2020, 10:54 AM
    if it can form one you can fold without providing an accumulator or empty value because you can use the monoid empty identity as the empty value and the associative operation as the accumulator
    c
    • 2
    • 24
  • g

    gabib

    02/18/2020, 2:27 PM
    Hello, I am giving a talk about FP and Arrow at a meetup this week and at Voxxed in March, is it ok if I use in my presentation arrow logos?
    👏 2
    🙌 2
    :arrow: 4
    s
    • 2
    • 2
  • r

    Rodrigo Silva

    02/18/2020, 4:33 PM
    Hello all. Can i build an entire Rest API with arrow + ktor without using OO (classes, inheritance ...)?
    p
    b
    +2
    • 5
    • 19
  • c

    Carter Youngblood

    02/18/2020, 10:37 PM
    thanks! - Ill give that a go - appreciate the response - love Arrow btw 🙂
    ❤️ 4
    m
    k
    s
    • 4
    • 7
  • g

    Gopal S Akshintala

    02/19/2020, 3:07 AM
    I have a situation. I have a repo which has a dependency
    DBClient
    , which is not in my hands (say a lib impl) and it returns me a concrete type, like
    IO<String>
    . Now I wish to have a generic repo and only commit to a concrete type at the edge of my application, like
    main()
    here. But I get a compiler error in repo as commented below, which is expected. Is there any idiomatic workaround to achieve what I desire for? Thanks.
    open class Repo<F>(
            private val dbClient: DBClient,
            M: Monad<F>
    ) : Monad<F> by M {
        fun get(): Kind<F, String> = fx.monad { 
            dbClient.get() // vvv Compiler error. This needs to be converted to generic Higher kind
        }
    }
    
    fun main() {
        val repo = Repo(DBClient(), IO.async())
        print(repo.get().fix().unsafeRunSync())
    }
    
    class DBClient {
        fun get() = IO { "abc" }
    }
    r
    • 2
    • 3
  • b

    Bob Glamm

    02/19/2020, 3:10 PM
    Is there a standard set of imports for Arrow that gets me (roughly) everything, kind of analogous to Scala cats:
    import cats._
    import cats.data._
    import cats.implicits._
    import cats.syntax._
    import cats.effect._
    ?
    r
    • 2
    • 1
  • r

    raulraja

    02/20/2020, 12:05 PM
    As we go into programming we would frequently represent things like a TwitterHandle with the type String. The ugly truth is that Twitter is already telling us String covers a lot more values than what a TwitterHandle should be. It does not have to be this way. We can get better types in Kotlin that guarantee some constraints at compile time with a flavor of type refinements. I based this example in the talk https://kwark.github.io/refined-in-practice/#1 by @kwark to show how its example around TwitterHandle could be modeled in the upcoming type proofs April release with Arrow Meta. We have an initial draft with some tests that show we can bring expressions that serve both for constant and runtime validation for more precise and safe types. The user does not need to learn any type-level predicates or a specialized DSL since predicates can be expressed as receiver functions whose expressions are evaluated at compile-time without contextual dependencies. The user just provides the rules to describe the type predicates and uses the Apis available in the std lib or other user-supplied libs that can run alongside the compiler class-path in a compiler plugin.
    RefinedTypes_kt.kt
    :arrow: 15
    🔝 9
    ❤️ 20
    m
    s
    +4
    • 7
    • 28
  • b

    Bob Glamm

    02/20/2020, 4:51 PM
    hmm, I really don't like declaring something like this as an extension method on F:
    fun <F> F.updateTimezone(ctx: DocumentContext): Kind<F, DocumentContext> where F: MonadThrow<F> { ... }
    (with arrow 0.10.x), but IIRC I am waiting for Arrow 1.0 to have the equivalent of Scala's
    (implicit MT: MonadThrow[F])
    , right?
    s
    r
    • 3
    • 11
  • c

    CLOVIS

    02/20/2020, 5:07 PM
    .let
    is
    map
    on an
    Option
    ?.
    notation is
    flatMap
    on an
    Option
    Your thoughts?
    s
    • 2
    • 2
  • b

    Bob Glamm

    02/20/2020, 10:41 PM
    Have you all tried disabling the Machine Learning plugin in IntelliJ to see if that improves editor performance? I have that turned off right now and IJ seems to be .. "better", if not good
    s
    • 2
    • 2
  • b

    Bob Glamm

    02/21/2020, 3:26 PM
    Does Arrow have a Monoid instance for endofunctions?
    m
    a
    • 3
    • 6
  • d

    dnowak

    02/22/2020, 1:29 PM
    I use version 0.10.5.-SNAPSHOT. Any ideas what I have done wrong?
    r
    s
    +2
    • 5
    • 15
  • m

    melatonina

    02/22/2020, 11:52 PM
    Hello. I'm trying to write my first comprehension like this:
    Either.monad<Exception>().fx {
    
    }
    but the IDE says there is no
    fx
    . If I go to the definition of
    Either.monad()
    , I see that it returns a
    EitherMonad<L>
    , which has a definition for
    fx
    . What's happening? That is an attempt to adapt the code from your comprehension tutorial. If, instead, I'm supposed to use
    Either.monad<Any>().binding {
    
    }
    then the problem is that I don't thave any
    binding
    method around.
    a
    s
    • 3
    • 5
  • g

    Gopal S Akshintala

    02/23/2020, 1:05 PM
    Hi, is the major (or only) application of HKT is to code effect agnostic libraries? I am not able to realize any benefit of using them in an application Domain logic, as the implementation of any application is hardly going to change (like from Rx2 to Coroutines or something) and even if I forsee a migration in future (like from blocking to non-blocking)), filling the domain code with HKTs, fx blocks and monad transformers might seem an overkill. Please help me understand if I missing anything. P.S: Also I recently referred to this talk by @raulraja [KotlinConf 2018 - Functional Programming in Kotlin with Λrrow by Raúl Raja Martínez](

    https://www.youtube.com/watch?v=VOZZTSuDMFE▾

    ) and he starts with let’s build a library!
    r
    • 2
    • 8
  • m

    Manuel Roblek

    02/24/2020, 9:48 AM
    Hi, I'm just getting started with arrow and I hope this is the right place to ask. First of all I'm using Iatest IntellIJ 2019.3.3 Whenver I add any arrow dependencies via gradle auto completion within IntelliJ becomes unusable and will be stuck in a constant loop of reloading ( see attached gif). Removing everything related to arrow from gradle will allow autocomplete to work normally again. Tried the obvious stuff in invalidating cache and checking the logs for anything out of the ordinary. Any ideas what might be the issue here?
    r
    p
    +3
    • 6
    • 16
  • c

    Carter Youngblood

    02/25/2020, 5:13 PM
    I am working on creating some kafka extension functions and I want to take a
    KStream<Either<Error, Result>>
    and create a
    Pair
    of
    KStream<Error>
    and
    KStream<Result>
    . I was not sure how to accomplish this using Either from arrow. We have some helpers in scala that do this now, and for my learning I wanted to do the same in kotlin - in scala it looks something like this -
    def forkValuesEither: (KStream[K, LV], KStream[K, RV]) = (
          kStream.flatMapValues(_.left.toSeq),
          kStream.flatMapValues(_.right.toSeq)
        )
    but I was not sure how to get to the value in arrow/kotlin of the either to return.
    r
    s
    • 3
    • 25
  • k

    kluck

    02/26/2020, 10:22 AM
    Hi, I get the following error when running tests, although it works correctly on standard runtime:
    java.lang.NoClassDefFoundError: arrow/typeclasses/MonadContinuation
    	at arrow.typeclasses.MonadFx$DefaultImpls.monad(Monad.kt:107)
    	at arrow.core.extensions.OptionFxMonad.monad(option.kt:223)
    	at arrow.core.extensions.OptionFxMonad.monad(option.kt:220)
    	at arrow.core.extensions.OptionKt.fx(option.kt:324)
    The incriminated code block:
    private fun Option<Duration>.moreThan5Minutes(compared: Option<Duration>) = (isEmpty() != compared.isEmpty()) || Option.fx {
            val first = bind()
            val second = compared.bind()
            abs(abs(first.toMinutes()) - abs(second.toMinutes())) >= FIVE_MINUTES
        }.getOrElse { false }
    In my gradle.kts:
    implementation(io.arrow-kt:arrow-fx:0.10.4)
    implementation(io.arrow-kt:arrow-syntax:0.10.4)
     Oh, and the test work when run through Android Studio 🤔 Any idea what might be causing this?
    j
    • 2
    • 2
  • p

    pakoito

    02/26/2020, 1:25 PM
    okay, so your problem is that you want to move from something implementation-specific like Rx to a generic Kind
    g
    • 2
    • 2
  • p

    pakoito

    02/26/2020, 1:26 PM
    doing an
    fx
    block with a single line
    !
    is the same as just pulling the thing you’re binding outside
    g
    • 2
    • 17
  • g

    Gopal S Akshintala

    02/27/2020, 2:10 PM
    Hi, I see
    Either.fx<L,R>{}
    works with only one type of
    Either<L,R>
    . Is there any way to work with different types of
    Either
    to avoid nested fold?
    val a: Either<Int, String> = "a".right()
        val b: Either<String, Int> = 1.right()
        
        Either.fx<String, Int> {
            val bind = a.bind() // ^^^ Compiler Error
            b.bind()
        }
    s
    • 2
    • 11
  • j

    Jonathan

    02/27/2020, 2:29 PM
    Hi, How to we deal with coroutines'
    Flow
    and Arrow's
    IO
    ? Here is an example of what I'd like to achieve. But it doesn't compilbe because
    IO.fx
    restrict suspension:
    val flow: Flow<Int> =
        flowOf(1, 2, 3)
    
    fun putStrLn(value: Any?): IO<Unit> =
        IO { println(value) }
    
    val program = IO.fx {
      flow.collect {
        !putStrLn(it)
      }
    }
    
    fun main() {
      program.unsafeRunSync()
    }
    s
    a
    • 3
    • 57
  • g

    Gopal S Akshintala

    02/28/2020, 11:11 AM
    Hi, I wish to short-circuit
    fx.async{}
    block below:
    fun <F> Async<F>.something(): Kind<F, Either<String, String>> = fx.async {
        val left = "1-left".left().just()
        // I wish to short-circuit here if either above is left
        "2-right".right()
    }
    This is what I could come up with:
    fun <F> Async<F>.something2(): Kind<F, Either<String, String>> = fx.async {
        Either.fx {
            !"1-left".left()
            "2-right".right().bind()
        }
    }
    Is there a better way than to use nested blocks?
    j
    s
    • 3
    • 14
  • r

    raulraja

    02/28/2020, 4:12 PM
    https://twitter.com/raulraja/status/1233353650338172931?s=19
    :arrow: 8
    👏 5
    t
    s
    • 3
    • 3
  • h

    Hugo

    02/29/2020, 7:27 PM
    Hey Guys, need some help. I have multiple Either’s and I want to collect the right from all of them to build an object. Something like this, but I’m not able to make this work:
    @Test
        fun combineEithers() {
            val name = randomEither(null, "Alfredo Lambda")
            val phone = randomEither(null, 55555555)
            val address = randomEither(null, listOf("1 Main Street", "11130", "NYC"))
    
            val result = Either.applicative<Profile>()
                .tupled(name, phone, address)
                .fix()
                .map { Profile(it.a, it.b, it.c) }
    
            println(result)
        }
    
        fun <K> randomEither(left: ResponseError?, right: K): Either<ResponseError, K> {
            return if (left != null) {
                Either.left(left)
            } else {
                Either.right(right)
            }
        }
    
        data class Profile(val name: String, val phone: Int, val address: List<String>)
    r
    • 2
    • 5
  • g

    Gopal S Akshintala

    03/01/2020, 7:43 AM
    Hi, I am referring to this [Error Handling Pattern using ApplicativeError](https://next.arrow-kt.io/docs/patterns/error_handling/#example--alternative-validation-strategies-using-applicativeerror) How can I extend for other datatypes (apart from
    FormField
    used in this example)? I could come-up with something like below, using inheritance, but I feel that’s not the ideal way, as I hv to touch the Framework code (
    Rules<F>
    ) every time I extend this for a new type. Cc: @raulraja
    interface FormFieldValidation<F> : ApplicativeError<F, Nel<ValidationError>> {
    ...// This has contain FormField.contains, FormField.maxLength, FormField.validateWithEmailRules() 
    }
    
    interface FormFieldValidation2<F> : ApplicativeError<F, Nel<ValidationError>> {
    ...// This has contain FormField2.contains, FormField2.maxLength, FormField2.validateWithEmailRules()
    }
    
    sealed class Rules<F>(A: ApplicativeError<F, Nel<ValidationError>>) : 
            ApplicativeError<F, Nel<ValidationError>> by A,
            FormFieldValidation2<F>,
            FormFieldValidation<F> {
    .....
    }
    r
    • 2
    • 78
  • p

    pakoito

    03/01/2020, 11:34 PM
    note that snapshots don’t refresh unless you clear them from the cache explicitly
    m
    • 2
    • 1
  • k

    kluck

    03/02/2020, 10:28 AM
    Hi, I'm trying to integrate IO with the #uniflow library, but I'm at a loss on how to tackle it… Uniflow already supports coroutines so it (supposedly) should be a breeze 😄 Heres how the syntax look like for coroutines (taken from uniflow github) :
    fun childIO() = setState { // -> See <https://github.com/uniflow-kt/uniflow-kt/blob/master/uniflow-core/src/main/kotlin/io/uniflow/core/flow/DataFlow.kt#L93>
        onIO {  // -> coroutine's IO : suspend fun <T> onIO(block: suspend CoroutineScope.() -> T) = withContext(<http://UniFlowDispatcher.dispatcher.io|UniFlowDispatcher.dispatcher.io>(), block = block)
            delay(100)
            repository.add("LongTodo")
            repository.getAllTodo().mapToTodoListState() // -> fun getAllTodo() : List<Todo>
                                                         // -> fun List<Todo>.mapToTodoListState() : TodoListState
        }
    }
    What I'm trying to have is a similar syntax to this, with a
    setState
    taking
    IO
    instead of suspending functions:
    fun getAllTodo(): IO<List<Todo>>
    fun childIO() = setState { getAllTodo().map { TodoListState(it) } }
    Any idea where I should start? I've seen that @Jorge Castillo commented on arrow issues in the uniflow github, maybe he'll know what I'm talking about ^^
    a
    j
    • 3
    • 3
Powered by Linen
Title
k

kluck

03/02/2020, 10:28 AM
Hi, I'm trying to integrate IO with the #uniflow library, but I'm at a loss on how to tackle it… Uniflow already supports coroutines so it (supposedly) should be a breeze 😄 Heres how the syntax look like for coroutines (taken from uniflow github) :
fun childIO() = setState { // -> See <https://github.com/uniflow-kt/uniflow-kt/blob/master/uniflow-core/src/main/kotlin/io/uniflow/core/flow/DataFlow.kt#L93>
    onIO {  // -> coroutine's IO : suspend fun <T> onIO(block: suspend CoroutineScope.() -> T) = withContext(<http://UniFlowDispatcher.dispatcher.io|UniFlowDispatcher.dispatcher.io>(), block = block)
        delay(100)
        repository.add("LongTodo")
        repository.getAllTodo().mapToTodoListState() // -> fun getAllTodo() : List<Todo>
                                                     // -> fun List<Todo>.mapToTodoListState() : TodoListState
    }
}
What I'm trying to have is a similar syntax to this, with a
setState
taking
IO
instead of suspending functions:
fun getAllTodo(): IO<List<Todo>>
fun childIO() = setState { getAllTodo().map { TodoListState(it) } }
Any idea where I should start? I've seen that @Jorge Castillo commented on arrow issues in the uniflow github, maybe he'll know what I'm talking about ^^
a

aballano

03/02/2020, 10:35 AM
Hi @kluck! I’m not familiar with the syntax of uniflow, but I think you might be able to make it work if you convert your IOs to a suspend function by calling
suspended()/suspendCancellable()
on it, so you would have
suspended fun getAllTodo(): List<Todo>
k

kluck

03/02/2020, 10:46 AM
@aballano That did the trick, thank you!
🙌 2
j

Jorge Castillo

03/02/2020, 10:46 AM
fun childIOError() = setState {
        onIO {
            error("Boom on IO")
        }
    }
Following docs, in
uniflow
all actions can run on a coroutine using a DSL prepared for it, functions like
onIO
onMain
,
onDefault
just translate to standard
withContext(IO)
,
withContext(Main)
,
withContext(Default)
. Same for
launchOnIO
,
launchOnMain
,
launchOnDefault
if you need to launch it not just switch the dispatcher. If you look at how the DSL functions are defined, you’ll find this: https://github.com/uniflow-kt/uniflow-kt/blob/5152c197131c7f9d8b3129a37017671c4aea49ae/uniflow-core/src/main/kotlin/io/uniflow/core/threading/Threading.kt Launch ones are defined over a coroutine scope, like:
fun CoroutineScope.launchOnIO(block: suspend CoroutineScope.() -> Unit) = launch(<http://UniFlowDispatcher.dispatcher.io|UniFlowDispatcher.dispatcher.io>(), block = block)
Those get
block
as a suspend function so you can pass an arrow `IO`one there by calling `suspended() or suspendCancellable()`as suggested by Alberto. Alternatively you can write an “overload” that enforces
block
to be an arrow
IO
instead, so you have both syntax available. Then you can `launch`the IO task inside with the new extension functions to run the passed IO scoped to the receiver scope. (This is just available starting on the snapshot 0.10.5) For the
onXXX
ones are suspend functions you can wrap into
IO.effect {}
🔝 2
☝️ 3
View count: 2