View IntroductionToMonoidsAndMonads.scala
This file contains 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
View ExpressionProblem1_1.scala
This file contains 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
trait Module { | |
type shape | |
} |
View Monad1Solution.scala
This file contains 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
import language.higherKinds | |
trait Monad1[M[_]] { | |
def id[A](a: A): M[A] | |
def compose[A,B,C](f: A => M[B], g: B => M[C]): A => M[C] | |
def flatMap[A,B](ma: M[A], f: A => M[B]): M[B] = | |
compose((_:Unit) => ma, f)(()) |
View Monad1Exercise.scala
This file contains 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
import language.higherKinds | |
trait Monad1[M[_]] { | |
def id[A](a: A): M[A] | |
def compose[A,B,C](f: A => M[B], g: B => M[C]): A => M[C] | |
def flatMap[A,B](ma: M[A], f: A => M[B]): M[B] = ??? | |
def join[A](mma: M[M[A]]): M[A] = ??? |
View scriptscalamonads.scala
This file contains 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
val sqrt = math.sqrt _ | |
val acos = math.acos _ | |
val divTen = (x:Double) => x/10.0 | |
sqrt(64.0) | |
divTen(8.0) | |
acos(0.8) |