Skip to content

Commit

Permalink
[REFACTOR]: Monad extends FlatMap too
Browse files Browse the repository at this point in the history
  • Loading branch information
csgn committed Sep 3, 2024
1 parent 2fd3e4d commit 0b76066
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/scala/kuram/monad/Monad.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package kuram
package monad

import applicative.Applicative
import flatmap.FlatMap

/**
*
Expand All @@ -35,10 +36,8 @@ import applicative.Applicative
* res0: List[Int] = List(3, 4, 5)
* }}}
*/
trait Monad[F[_]] extends Applicative[F] {
trait Monad[F[_]] extends Applicative[F] with FlatMap[F] {
extension [A](fa: F[A]) {
def flatMap[B](f: A => F[B]): F[B]

override def map[B](f: A => B): F[B] =
fa.flatMap(a => pure(f(a)))

Expand Down

0 comments on commit 0b76066

Please sign in to comment.