How to understand the monad in scala

I just realized what a type of constructor and state of a higher type are, and now I'm trying to understand the Monad. Here's what the Monaddash looks like in scalaz:

trait Monad[F[_]] extends Applicative[F] with Bind[F] { self =>
  ////

  override def map[A,B](fa: F[A])(f: A => B) = bind(fa)(a => point(f(a)))
  //The rest is omitted

}

The question is, I don’t understand why Monadis a higher type of type? We have standard monads List[T], Option[T]which are not more sort types.

I am not an expert in the Theory category, so I see the monad as a container with monad laws.

Why don't we just declare the monad as follows:

trait Monad[V]{
    //...
}

No higher view.

How does a standard font Option[T]look like a subclass in this case, for example?

+6
source share
1 answer

, ?

, , - pure, type :

// Doesn't compile
trait Monad[V]{
  def pure[A](a: A): V[A]
}

, , V[A] , , , * -> *

[T] monad ,

, Monad ( Functor, ) , , Monad[List], , T List - . , Monad .

[T], Option [T], .

. , T List[T] Option[T], T . , Option[T] * -> *, List Option[List[T]].

+6

All Articles