Razvan
02/26/2021, 6:58 PMresult4k
if I got a lens declared as:
Body.auto<T>().toLens().asResult()
I can only use extract
lens function I can’t use inject
to it, so. what’s best practice ?
val requestLens = Body.auto<T>().toLens()
val responseLens = responseLens.asResult()
dave
02/26/2021, 7:00 PMRazvan
02/26/2021, 7:05 PMresult4k
a bind
like kotlin-result
does. it’s kinda painful sometimes flatmapping inside flatmap to keep access to a previous result.dave
02/26/2021, 7:08 PMnatpryce
02/26/2021, 9:38 PMRazvan
02/27/2021, 12:00 PMval tLens = Body.auto<T>().toResultLens()
val response: Result<T, LensFailure> = tLens(httpResponse)
val request: Request = tLens(Request(GET), tObj)
Maybe in BiDiBodyLensSpec
having a toResultLens
that instead of
{ getLens(it).let { if (it.isEmpty()) throw LensFailure(metas.map(::Missing), target = it) else it.first() } },
dose something like
{ getLens(it).let { if (it.isEmpty()) Failure(LensFailure(metas.map(::Missing), target = it)) else Success(it.first()) } },
The problem is that it changes the signature and mess up with all the rest…
All this for not declaring another variable, not sure it really worth it 🙂 (especially as I still need another variable for the lens usage in ContactRoute, unless… NO STOP!! )