Skip to content

Instantly share code, notes, and snippets.

Avatar

Grzegorz Balcerek grzegorzbalcerek

View GitHub Profile
View Monad1Solution.scala
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
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
val sqrt = math.sqrt _
val acos = math.acos _
val divTen = (x:Double) => x/10.0
sqrt(64.0)
divTen(8.0)
acos(0.8)
You can’t perform that action at this time.