Created
November 5, 2020 21:16
-
-
Save rupeshtr78/aba1b58c2dee3ab12aa3dfcc582307c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MoniodsFunctorMonad | |
object MonadBasic { | |
trait Functor[T] { | |
def map[Y](f: T => Y): Functor[Y] | |
} | |
trait Monad[T] extends Functor[T] { | |
def unit[Y](value: Y): Monad[Y] | |
def flatMap[Y](f: T => Monad[Y]): Monad[Y] | |
override def map[Y](f: T => Y): Monad[Y] = | |
flatMap(i => unit(f(i))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment