This repository was archived by the owner on Nov 29, 2020. It is now read-only.
This repository was archived by the owner on Nov 29, 2020. It is now read-only.
Rewriting #9
Open
Description
Possible syntax:
trait Functor[F[_]] {
def map[A, B](fa: F[A])(f: A => B): F[B]
}
object Functor {
def fusion[F[_], A, B, C](fa: F[A], f: A => B, g: B => C)
(implicit F: Functor[F], R: Rewrites): Rewrite =
F.map(F.map(fa)(f))(g) rewriteTo F.map(fa)(f andThen g)
}
///////////////////////////////////
///////////////////////////////////
class rewrite extends annotation.StaticAnnotation
final class Rewrite private()
final class Rewrites private ()
implicit class RewriteSyntax[A](val from: A) {
def rewriteTo(to: A)(implicit R: Rewrites): Rewrite = ???
}
R : Rewrites
is there to guarantee that fusion
won't be called by the user.