Reader monad - how does it conform to Monad interface?
问题 I'm learning category theory. I understand the concept of reader monad, it's even pretty easy to implement: case class Reader[DEP, A](g: DEP => A) { def apply(dep: DEP): A = g(dep) def map[B](f: A => B): Reader[DEP, B] = Reader(dep => f(apply(dep))) def flatMap[B](f: A => Reader[DEP, B]): Reader[DEP, B] = Reader(dep => f(apply(dep)) apply dep) } However, I have problems implementing it with constraint to some generic Monad interface, i.e trait Monad[A] { def pure(a: A): Monad[A] def map[B](f: