Skip to content

Instantly share code, notes, and snippets.

val sqrt = math.sqrt _
val acos = math.acos _
val divTen = (x:Double) => x/10.0
sqrt(64.0)
divTen(8.0)
acos(0.8)
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] = ???
@grzegorzbalcerek
grzegorzbalcerek / Monad1Solution.scala
Created April 27, 2015 14:28
Monad Exercises Solutions
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)(())
@grzegorzbalcerek
grzegorzbalcerek / ExpressionProblem1_1.scala
Last active April 7, 2016 21:48
The Expression Problem
trait Module {
type shape
}