Kleisli 如何成为 monad Transformer?

How is Kleisli a monad Transformer?

猫中 Monad 变形金刚的一些定义。

EitherT[F[_], A, B] is a lightweight wrapper for F[Either[A, B]] that makes it easy to compose Eithers and Fs together. To use EitherT, values of Either, F, A, and B are first converted into EitherT, and the resulting EitherT values are then composed using combinators.

OptionT[F[_], A] is a light wrapper on an F[Option[A]]. Speaking technically, it is a monad transformer for Option, but you don’t need to know what that means for it to be useful. OptionT can be more convenient to work with than using F[Option[A]] directly.

我理解这个概念,甚至看到一些有趣的讨论:Monad transformers down to earth by Gabriele Petronella

我了解 Reader Monad,Kleisli 只是一个概括。

我不明白的是下面的声明,说它是一个 monad 转换器。我们究竟在堆放什么?我没有看到 2 monad 被堆叠在这里....

Kleisli can be viewed as the monad transformer for functions. Recall that at its essence, Kleisli[F, A, B] is just a function A => F[B], with niceties to make working with the value we actually care about, the B, easy. Kleisli allows us to take the effects of functions and have them play nice with the effects of any other F[_].

有什么想法吗?

Monad 转换器 EitherT[F[_], A, B]F[Either[A, B]] 的包装器)在我们考虑两个 monad 的组合时出现:F(外部 monad)和 Either[A, ?](内部 monad) .

Monad 转换器 OptionT[F[_], A]F[Option[A]] 的包装器)出现在我们考虑两个 monad 的组合时:F(外部 monad)和 Option(内部 monad) .

Monad 转换器 Kleisli[F, A, B]A => F[B] 的包装器)在我们考虑两个 monad 的组合时出现:A => ?(外部 monad)和 F(内部 monad) .