Mic*_*ael 17 monads functional-programming scala kleisli
阅读本文后,我理解>=>(Kleisli arrow)只是一个组合函数的高阶函数,它返回"monadic values".例如:
val f: A => M[B] = ... val g: B => M[C] = ... val h: A => M[C] = f >=> g // compose f and g with Kleisli arrow
它看起来像是一个简单的"简单"函数组合(即返回简单值的纯函数):
val f: A => B = ... val g: B => C = ... val h = f andThen g; // compose f and g
现在我猜这个"简单"的构图andThen符合某些规律
f andThen g == g和g andThen f == g对身份的功能:f[A](a:A):A = a(f1 andThen f2) andThen f3 == f1 andThen (f2 andThen f3)现在我的问题是:
>=>遵守这些法律,其中的身份是f(a:A) = M[a].unit(a)?