kyleg
12/19/2019, 7:24 PMJannis
12/19/2019, 8:08 PMIO
in progress which turns IO<A>
into IO<E, A>
which makes the failure conditions of your IO
explicit. This means you can easily predict and handle how IO
will fail and you can even define IO<Nothing, A>
as an IO
that should never fail. (It still can but IO<Nothing, A>
denotes unexpected failure. The mtl pattern for this is EitherT<ForIO, E, A> == IO<Either<E, A>>
, but the inbuilt one is much easier to use.
The next step is adding IO<R, E, A>
which adds a context to your IO
. This means you will have read access to context from within IO
. The mtl pattern for this is Kleisli<ForIO, R, A> == (R) -> IO<A> == ReaderT<ForIO, R, A>
, but again in-built it's much nicer. This basically replaces the need for DI.
It is still very valuable to learn how to use the specific monads tho, just a sneak peak on how arrow will make this practical even in kotlin 😅jimn
12/19/2019, 9:08 PMJannis
12/19/2019, 9:10 PMkyleg
12/20/2019, 3:07 AMkyleg
12/20/2019, 3:07 AM