Skip to content

Instantly share code, notes, and snippets.

@frojasg
Created April 20, 2015 01:12
Show Gist options
  • Save frojasg/1cac6d6ccc2dc82c31e2 to your computer and use it in GitHub Desktop.
Save frojasg/1cac6d6ccc2dc82c31e2 to your computer and use it in GitHub Desktop.
Class defined during the first week of the course reactive-002
trait Generator[+T] {
self =>
def generate: T
def map[S](f: T => S): Generator[S] = new Generator[S] {
def generate = f(self.generate)
}
def flatMap[S](f: T => Generator[S]): Generator[S] = new Generator[S] {
def generate = f(self.generate).generate
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment