Attila Domokos
01/08/2020, 9:47 PMEitherT.monad<ForIO, AppError>(IO.monad()).fx.monad {
looks a bit scary. Is there a simpler way to express this?Jannis
01/08/2020, 10:12 PMAttila Domokos
01/08/2020, 10:13 PMJannis
01/08/2020, 10:58 PMEitherT<F, E, A> == Kind<F, Either<E, A>>
and so on for others.
Skimmed the post:
Avoiding State and Writer for the reasons listed is really good (although if you know about those caveats its manageable)
Avoiding ExceptT is bs imo because the concurrent instance for EitherT (arrows ExceptT) is pretty clear about concurrent semantics + runtime errors are always a problem with or without it.
The ReaderT pattern is nice, but heavily relies on typeclasses, also note that ReaderT does not compose very well. Btw just like IO is going to get an inbuilt EitherT with IO<E, A>, we are also getting an inbuilt ReaderT (Kleisli in arrow) in the form of IO<R, E, A>.
On the topic of mtl: To do mtl effectively you have to be abstract in your monad stack, so you have to use constraints in the form of arguments which are typeclass instances. If you don't you loose the benefits in terms of testability and freedom to choose instances for different scenarios, which imo is the main point of mtl. Code looks like this then: fun doSomething(MR: MonadReader<F, R>): Kind<F, A>
This will be a lot nicer in the future when instances are resolved by a compiler plugin instead of manually passing. There is however one downside: IO
. There is no MonadIO<F>
typeclass (not sure why) so there is no way to introduce IO
without fixing F
atm. (You can mark the function as suspend to, but thats not the whole package^^). I'll open an issue to track all problems I have with mtl and propose a few solutions, some require more work and I am busy for a while, so I'll likely not get to it before february 😕Jannis
01/08/2020, 11:05 PMMonadIO
missing is bs, we have MonadDefer
and higher Concurrent
etc, those model almost all IO
behaviour so we can probably skip it in favor of thoseJannis
01/08/2020, 11:05 PMIO
codeJannis
01/08/2020, 11:13 PM