tavish pegram
05/27/2020, 12:50 AMsuspend modifier) or is it best practice to just use IO to run the effects at the boundary of the system and stick to suspend to indicate impurity?
For example
suspend fun printAString(s: String): Unit
suspend fun printAString(s: String): IO<Unit>
At the moment I am attempting to stick to a ports and adapters architecture with suspend for impure functions generally, IO return types at the service level, and actually unwrapping/running the IO at the controllers. The data is also the boundary but it didn't make a lot of sense to me to unwrap anything there so I've just been using suspend in the repos.
As a follow-up, does anyone know if it is possible to custom alias the modifier to something like impure to distinguish from coroutine suspend methods? Or am I thinking about that incorrectly? Like
impure fun printAString(s: String): Unit
Is that something we might want to use Arrow.Meta for?
Thanks!Marcin Gryszko
05/27/2020, 6:36 AMfun printAString(s: String): IO<Unit>?
In my view, returning IO documents sufficiently that the function has side effects.tim
05/27/2020, 6:45 AMstojan
05/27/2020, 8:43 AMsuspend OR IO , both suspend and IO doesn't really make sense 🙂stojan
05/27/2020, 8:44 AMsuspend to IO using IO.effect or from IO to suspend using .suspended()tavish pegram
05/27/2020, 12:08 PMtim
05/27/2020, 12:33 PMstojan
05/27/2020, 1:08 PMIO , e.g. switching threads, racing, parMap , parTraverse etc....stojan
05/27/2020, 1:09 PM