Skip to content

Instantly share code, notes, and snippets.

@vvviiimmm
Last active April 23, 2017 16:34
Show Gist options
  • Select an option

  • Save vvviiimmm/e30fdba1be5f4e11da57bdd2133f9df7 to your computer and use it in GitHub Desktop.

Select an option

Save vvviiimmm/e30fdba1be5f4e11da57bdd2133f9df7 to your computer and use it in GitHub Desktop.
abstract class LazyFunctor[F[_], A] { self =>
// should be implemented as a composition of transformations
def transformation[B](f: A => B): F[B]
// apply transformations and get our value back
def run: F[A] = transformation(identity)
// interace 'map' to be used as functor
def map[B](f: A => B): LazyFunctor[F, B] = new LazyFunctor[F, B] {
def transformation[C](g: B => C): F[C] = self.transformation(g compose f)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment