Thanks for the answer <@U4UGS5FC7>. I am using th...
# arrow
l
Thanks for the answer @raulraja. I am using the transformer stack in my solution. I have this code:
Copy code
fun fetchAllPayments(): Reader<PaymentsDeps, IO<List<Payment>>> =
        ReaderApi.ask<PaymentsDeps>()
                .map { deps ->
                         IO.async<List<Payment>> { either ->
                             async {
                                 either(queryForPayments(deps.apiClient).toEither())
                             }
                         }
                     }


fun queryForPayments(apiClient: ApiClient): Try<List<Payment>> =
        Try { apiClient.getPayments() }
I would just like to aggregate a log result in my second function. Like this:
Copy code
fun queryForPayments(apiClient: ApiClient): Try<WriterT<String, List<Payment>>> =
        Try { apiClient.getPayments().put("The computation worked just fine!") }
This would also work:
Copy code
fun queryForPayments(apiClient: ApiClient): Try<Pair<String, List<Payment>>> =
        Try { apiClient.getPayments() to "The computation worked just fine!" }
But it looks less elegant. By passing the log as a result of the function, I don't have to cause side effects in the function, then I can print the log results in a later moment.