Skip to content
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
Open
@sir-wabbit

Description

@sir-wabbit

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions