The following PR encapsulates the application concerns in a single datatype representing a Monad transformer that allows monadic computation and encapsulation of the following Application concerns:
typealias Result<A> = Kleisli<EitherTF<Future.F, CharacterError>, GetHeroesContext, A>
An Async Result can handle dependency injection of GetHeroesContext values thanks to Kleisli which is the same as a Reader monad but parametric to other monads in this case Future whereas Reader is parametric to the Id monad.
An AsyncResult is a MonadError<AsyncResult.F, CharacterError> able to handle and raise errors in the context of CharacterError.
The nested EitherT over Future allows us to bind directly to the underlying A value when using flatMap and monadic comprehensions.
This PR also demonstrate the use of monadic comprehensions thanks to kategory a typed FP library for the Kotlin programming language.
The following PR encapsulates the application concerns in a single datatype representing a Monad transformer that allows monadic computation and encapsulation of the following Application concerns:
An Async Result can handle dependency injection of
GetHeroesContext
values thanks toKleisli
which is the same as a Reader monad but parametric to other monads in this caseFuture
whereasReader
is parametric to theId
monad.An
AsyncResult
is aMonadError<AsyncResult.F, CharacterError>
able to handle and raise errors in the context ofCharacterError
.The nested
EitherT
overFuture
allows us to bind directly to the underlyingA
value when usingflatMap
and monadic comprehensions.This PR also demonstrate the use of monadic comprehensions thanks to kategory a typed FP library for the Kotlin programming language.