Marko Novakovic
07/26/2021, 7:48 AMEither
and calls itself functional programming nor something too complicated for purposes of showing theory in practice.simon.vergauwen
07/26/2021, 7:51 AMsuspend
+ Either
with some concurrency/parallelism on top.
Sometimes Validated
to accumulate errors when validating a form, or Ior
when I need to figure out all failures and all success.
Besides that I use Arrow Fx Coroutines a lot, there is a lot of useful operators to compose suspend
in parallel, or repeating/retrying with compose-able Schedules, compose-able Resources (concurrent/parallel), etcstojan
07/26/2021, 7:53 AMsimon.vergauwen
07/26/2021, 7:57 AMthanh
07/26/2021, 8:07 AMsimon.vergauwen
07/26/2021, 8:11 AMMarko Novakovic
07/26/2021, 8:13 AMMarko Novakovic
07/26/2021, 8:16 AMMarko Novakovic
07/26/2021, 8:16 AMIvan Dugalic
07/26/2021, 10:21 AMIvan Dugalic
07/26/2021, 10:37 AMstyle.
Kotlin is wonderful, and Kotlin idiomatic Arrow is a cherry on the top 😉carbaj0
07/26/2021, 10:44 AMMarko Novakovic
07/26/2021, 11:18 AMraulraja
07/26/2021, 12:03 PMIvan Dugalic
07/26/2021, 2:28 PM<https://github.com/fraktalio/fmodel/tree/main/domain>
) is pure computation and behaviour. The Application lib (<https://github.com/fraktalio/fmodel/tree/main/application>
) is more opinionated in regarding to the runtime target. At the moment, I am proposing couple of interfaces (eg. <https://github.com/fraktalio/fmodel/blob/main/application/src/main/kotlin/com/fraktalio/fmodel/application/EventRepository.kt>
) with `suspend`ing only. I guess that Flow API is something that can be added as well. Thanks for suggestion!Ivan Dugalic
07/26/2021, 2:38 PMsimon.vergauwen
07/26/2021, 2:51 PMFlow<A>
or a sequence of suspend () -> A
composes in all situations, and suspend () -> A
only composes for single element effects.
So Flow<A>
can also seen as a “abstraction” over suspend () -> A
where you don’t know the amount of elements it will result in,
when using such approaches I’ve seen that it almost always results in nicer/better leaner apps.
Since you gain control over the sequencing of suspension, you can gain more power over pull-based things.
It becomes much easier to add rate limiters etc, which is composition around a sequence of suspend () -> A
.simon.vergauwen
07/26/2021, 2:53 PMsuspend () -> A
, but I found that in places where you need to deal with things such as rate limiters the resulting code always gets rather complex while it can be implemented as a generic operation over Flow<A>
.Ivan Dugalic
07/26/2021, 3:05 PMFlow/Flux
to the `suspend () -> A`/`Mono` is an important step to more robust streaming API.simon.vergauwen
07/26/2021, 3:07 PMIvan Dugalic
07/26/2021, 3:11 PMIvan Dugalic
07/27/2021, 12:00 PMIvan Dugalic
07/27/2021, 12:00 PMinterface EventRepository<C, E> {
suspend fun C.fetchEvents1(): Either<Error.FetchingEventsFailed, Flow<E>>
fun C.fetchEvents2(): Flow<Either<Error.FetchingEventsFailed, E>>
fun C.fetchEvents3(): Flow<E>
}
Ivan Dugalic
07/27/2021, 12:00 PMIvan Dugalic
07/27/2021, 12:05 PMIvan Dugalic
07/27/2021, 12:06 PMsimon.vergauwen
07/27/2021, 12:06 PMFlow<E>
requires side-effects, and it can fail with Error.FetchingEventsFailed
2. This is probably the most promising signature yes. It’ssimon.vergauwen
07/27/2021, 12:06 PMsimon.vergauwen
07/27/2021, 12:08 PMsimon.vergauwen
07/27/2021, 12:08 PMsuspend
also by wrapping that suspend
into Flow
before you actually emit thingssimon.vergauwen
07/27/2021, 12:09 PMflow { setUp() }.concatFlatMap { flowOfEvents() }
Ivan Dugalic
07/27/2021, 12:12 PMIterable
is no more present.simon.vergauwen
07/27/2021, 12:13 PMIvan Dugalic
07/27/2021, 12:13 PMIvan Dugalic
07/27/2021, 12:15 PMIvan Dugalic
07/27/2021, 12:15 PMsimon.vergauwen
07/27/2021, 12:16 PMIvan Dugalic
08/01/2021, 12:27 PM<https://github.com/fraktalio/fmodel/pull/33>
. It is still work in progress and sorry for one big commit 😞 (it make sense to browse the branch directly: <https://github.com/fraktalio/fmodel/tree/feature/flow>
)Ivan Dugalic
08/01/2021, 12:33 PMJörg Winter
08/11/2021, 9:36 AMIvan Dugalic
08/11/2021, 10:29 AM