Last active
April 23, 2017 16:34
-
-
Save vvviiimmm/e30fdba1be5f4e11da57bdd2133f9df7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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