dnowak
03/06/2020, 3:05 PMaballano
03/06/2020, 3:06 PMaballano
03/06/2020, 3:07 PMsimon.vergauwen
03/06/2020, 3:13 PM0.10.5
at this point is IO<E, A>
.dnowak
03/06/2020, 3:18 PMIO<E, A>
is the reason I wanted to play with 0.11.simon.vergauwen
03/06/2020, 3:19 PMIO<E, A>
did not change a lot compared to IO<A>
.
What’ll find is you’ll have IO.raiseError
and IO.raiseException
, and additional error handlers to deal with them.dnowak
03/06/2020, 3:19 PMIO.fx {
- compiler has two candidate functions and does not know which one to choose. So I wanted to refer to documentation…simon.vergauwen
03/06/2020, 3:19 PM0.10.5
and the work on the docs and finalizing the API will follow.simon.vergauwen
03/06/2020, 3:20 PMNothing
is quite pervasive throught the codebasesimon.vergauwen
03/06/2020, 3:20 PMIO.fx<Nothing, Int>
or IO.fx<DomainError, Int>
is what you’re looking fordnowak
03/06/2020, 3:22 PMfun crate(command: CreateLedgerCommand): IO<CreateError, Unit> = IO.fx<CreateError, Unit> {
simon.vergauwen
03/06/2020, 3:23 PMaballano
03/06/2020, 3:23 PMsimon.vergauwen
03/06/2020, 3:24 PMaballano
03/06/2020, 3:24 PMaballano
03/06/2020, 3:24 PMsimon.vergauwen
03/06/2020, 3:24 PMval program = IO<CreateError, Unit> = IO.fx<CreateError, Unit>
should be inferable, no?aballano
03/06/2020, 3:24 PMaballano
03/06/2020, 3:24 PMdnowak
03/06/2020, 3:25 PMval (ledger) = getLedger(command.ledgerId)
I get error that there is no component1 functionaballano
03/06/2020, 3:25 PMaballano
03/06/2020, 3:25 PMaballano
03/06/2020, 3:26 PMsimon.vergauwen
03/06/2020, 3:26 PMfun <A> IO.Companion.fx
overload which fixes to Nothing
. Maybe you need disambiguate because of that.dnowak
03/06/2020, 3:26 PMsimon.vergauwen
03/06/2020, 3:26 PMsimon.vergauwen
03/06/2020, 3:27 PMval ((a, b, c, d)) = parTupled(fa, fb, fc, fd)
aballano
03/06/2020, 3:27 PM_
😄aballano
03/06/2020, 3:27 PMval (_) = IO { … }
aballano
03/06/2020, 3:28 PMsimon.vergauwen
03/06/2020, 3:28 PMsimon.vergauwen
03/06/2020, 3:29 PMaballano
03/06/2020, 3:29 PMdnowak
03/06/2020, 3:29 PM.bind()
aballano
03/06/2020, 3:30 PMraulraja
03/06/2020, 3:34 PMdnowak
03/06/2020, 3:36 PMdnowak
03/06/2020, 3:36 PMfun crate(command: CreateLedgerCommand): IO<CreateError, Unit> = IO.fx<CreateError, Unit> {
val ledger = getLedger(command.ledgerId).bind()
}
simon.vergauwen
03/06/2020, 3:37 PMgetLedger
?dnowak
03/06/2020, 3:37 PMtypealias GetLedger = (LedgerId) -> IO<RepositoryError, Ledger>
typealias StoreEvents = (List<Any>) -> IO<EventStoreError, Unit>
dnowak
03/06/2020, 3:39 PMIO<Either<E, A>>
. I hoped that Bi IO will let me get rid of EitherT , which was needed to map errors.simon.vergauwen
03/06/2020, 3:40 PMEitherT
simon.vergauwen
03/06/2020, 3:41 PMdnowak
03/06/2020, 3:42 PMsimon.vergauwen
03/06/2020, 3:42 PMRepositoryError
to CreateError
unless you map the error using something like flatMapLeft
, fallbackWith
, handleErrorWith
or another error handler.simon.vergauwen
03/06/2020, 3:43 PMsealed class CreateError {
sealed class RepositoryError : CreateError {
//...
}
sealed class EventStoreError : CreateError {
//...
}
}
simon.vergauwen
03/06/2020, 3:43 PMRepositoryError
within IO.fx<CreateError, A>
simon.vergauwen
03/06/2020, 3:44 PMfx
to go from RepositoryError
to CreateError
otherwise and it doesn’t know how to flatMap
.dnowak
03/06/2020, 3:50 PMdnowak
03/06/2020, 3:50 PMsimon.vergauwen
03/06/2020, 3:51 PMCreateError
and you’re trying to bind RepositoryError
which is a compilation error since the domain errors don’t alignsimon.vergauwen
03/06/2020, 3:51 PMflatMap
you’ll see that it’s unrelated to bind
or fx
.dnowak
03/06/2020, 3:52 PMsimon.vergauwen
03/06/2020, 3:52 PMIO<E, A>
is very welcome since we’re still polishing the final APIsimon.vergauwen
03/06/2020, 3:53 PMdnowak
03/06/2020, 3:54 PM.mapLeft
function 🙂. Simple error mapping would be easier to read:
.flatMapLeft { e -> IO.raiseError(CreateError.Unexpected("error")) }
simon.vergauwen
03/06/2020, 3:55 PMdnowak
03/06/2020, 3:56 PMJannis
03/06/2020, 3:58 PMhandleErrorWith
do that? Or ist that fixed to the same E
? Probably wouldn't hurt inference to allow it to return a different E
Jannis
03/06/2020, 3:59 PMMonadError
-instance would then end up having different behavior so using a different operator name might be bettersimon.vergauwen
03/06/2020, 4:14 PMhandleErrorWith
covers E
and Throwable
aballano
03/06/2020, 4:48 PMsimon.vergauwen
03/06/2020, 5:01 PM