raulraja
06/12/2019, 10:11 AMKind<F, A>.map(f: (A) -> B): Kind<F, B>
vs map(fa: F[A], f: (A) -> B): F[B]
in catsraulraja
06/12/2019, 10:13 AMraulraja
06/12/2019, 10:14 AMraulraja
06/12/2019, 10:17 AM!
imperatively in any fx block and that is a huge difference in terms of user experience and syntax.earroyoron
06/12/2019, 3:41 PMtypealias LoginResponse = Coproduct4<FatalLoginProblem, WrongCredentials, LoginNeedsMore, SuccessCompletedLogin>
a LoginResponse
is only 1 of the 4 types or I should create Unit
onto the useless.
PD: I think as we use First(FatalLoginProblem())
the answer is it holds just 1, but I am not sure because of the fold syntax where I always should use all “branches” for the coproduct.thanerian
06/12/2019, 3:44 PMraulraja
06/12/2019, 4:01 PMEither
and a product represents all declared properties (tuples, hlist, data classes)Bob Glamm
06/13/2019, 2:35 PMdef genFeed[F[_]: Monad:
Logging: UserDatabase:
ProfileDatabase: RedisCache:
GeoIPService: AuthService:
SessionManager: Localization:
Config: EventQueue: Concurrent:
Async: MetricsManager]: F[Feed] = ???
Bob Glamm
06/13/2019, 2:35 PMpakoito
06/13/2019, 2:40 PMpakoito
06/13/2019, 2:40 PMpakoito
06/13/2019, 2:40 PMBob Glamm
06/13/2019, 2:42 PMS3Ops<F>
, LoggingOps<F>
, LoggedS3Ops<F>: S3Ops<F>, LoggingOps<F>
instead of all at once like the aboveBob Glamm
06/13/2019, 2:43 PMBob Glamm
06/13/2019, 3:07 PMcarbaj0
06/15/2019, 12:17 PMsimon.vergauwen
06/15/2019, 12:23 PMctx
while the second doesn't and leaves the ctx
unused.andreworobator
06/16/2019, 11:03 PMpakoito
06/17/2019, 12:00 AMpakoito
06/17/2019, 12:00 AMpakoito
06/17/2019, 12:00 AMkluck
06/17/2019, 9:01 AMIO.async()
which works great for a single barcode scanning.
fun startScanning(): IO<ScanItem> = IO.async()
.async { callback: (Either<Throwable, ScanItem>) -> Unit ->
resume()
decodeContinuous(object : BarcodeCallback {
override fun possibleResultPoints(resultPoints: MutableList<ResultPoint>?) {}
override fun barcodeResult(result: BarcodeResult) {
callback(ScanItem(result.text, result.barcodeFormat.toScanItemFormat()).right())
}
})
}
// inside my activity
scanner.startScanning()
.map {
Timber.d("Scanned item: $it")
scanner.setStatusText(it.data)
}
.unsafeRunAsync { result -> result.mapLeft { Timber.e(it) } }
What is the idiomatic way to handle multiple barcode scans?pakoito
06/17/2019, 9:08 AMpakoito
06/17/2019, 9:12 AMscanner.startScanning()
.flatMap { item ->
IO { Timber.d("Scanned item: $item") }.map { item }
}.flatMap {
scanner.setStatusText(it.data)
}
.handleErrorWith { err ->
IO { Timber.e(err) }
}.unsafeRunAsync { }
which means you can convert to fx
IO.fx {
val (item) = scanner.startScanning()
Timber.d("Scanned item: $item")
!scanner.setStatusText(item.data)
}.handleErrorWith { err ->
IO { Timber.e(err) }
}.unsafeRunAsync { }
pakoito
06/17/2019, 9:13 AMarrow-streams
.pakoito
06/17/2019, 9:14 AMpakoito
06/17/2019, 9:16 AMfun scanOne() =
scanner.startScanning()
map(scanOne(), scanOne(), scanOne()) { codeA, codeB, codeC ->
scanner.setStatusText(...)
}.flatten()
.handleErrorWith { err ->
IO { Timber.e(err) }
}.unsafeRunAsync { }
pakoito
06/17/2019, 9:19 AMparMap
on it. Same code otherwisekluck
06/17/2019, 9:49 AMpakoito
06/17/2019, 10:15 AMsequence
for it