这是我以前的question的后续。看起来我仍然没有得到它。现在我试图编写返回作家 monad的函数。克莱斯利箭头与作家在斯卡拉。为什么不编译?
scala> val f = {x:Int => Writer("doing " + x + ";", x + 1)} f: Int => scalaz.WriterT[scalaz.Id.Id,String,Int] = scala> Kleisli(f) >=> Kleisli(f) :16: error: no type parameters for method apply: (f: A => M[B])scalaz.Kleisli[M,A,B] in object Kleisli exist so that it can be applied to arguments (Int => scalaz.WriterT[scalaz.Id.Id,String,Int]) --- because --- argument expression's type is not compatible with formal parameter type; found : Int => scalaz.WriterT[scalaz.Id.Id,String,Int] required: ?A => ?M Kleisli(f) >=> Kleisli(f)
为什么不编译?
'参数表达式的类型与形式参数类型不兼容; 找到:Int => scalaz.WriterT [scalaz.Id.Id,String,Int] 必需:?A =>?M' –