https://kotlinlang.org logo
#arrow-contributors
Title
# arrow-contributors
m

Marc

10/28/2021, 11:11 AM
as commented in the meeting @raulraja @simon.vergauwen @Imran/Malic @Javier here I’m sharing a gist with a snapshot of the idea
👍 2
👍🏽 1
notice that I’m not using `sealed`fun interfaces because I’m running the code in a multiplatform project and somehow the inspector doesnt like it but the main idea is to use them together
j

Javier

10/28/2021, 11:12 AM
context? I wasn't in the meeting hahah
looks like something to try to use with proofs maybe?
m

Marc

10/28/2021, 11:17 AM
sorry I confused you then hahaha
I’m trying to abstract somehow a clean architecture
Repository <- DataSource
(called Service in this gist)
where a Service can represent a CRUD operation and then we would be able to implement some
defaul
handy implementations like a cache repository that provides a policy to retrieve data or providing some default services to store data (in this case a simple Map. The final purpose is being able to build up this in a lego-like way
r

raulraja

10/28/2021, 11:37 AM
@Marc it looks like it’s already composable, what is it that you don’t like from it or wish it did differently?
m

Marc

10/28/2021, 11:44 AM
something I don’t like too much is this part specificly:
Copy code
/**
 * Mapping a put service require bidirectional mapping input -> output -> input
 */
fun <K, A, B> Service<Put<K, A>, A>.map(input: (B) -> A, output: (A) -> B): Service<Put<K, B>, B> =
    Service { (arg, value) -> invoke(Put(arg, input(value))).map(output) }
the fact that
Put
requires the type make sme imposible to do a regular mapping like others
because mapping
Service<Put<K, A>, A>
would return
Service<Put<K, A>, B>
simple example i have in mind:
Copy code
serviceA: Service<Put<String, EntityUser>, EntityUser>

//I'd like
service.map(entityToDomain) -> to be Service<Put<String, User>, User>

//but instead I have
Service<Put<String, EntityUser>, User> //that's inconsistent
thats why I need the two way mapping in order to make the conversion
3 Views