[deprecated]dotty version of paradise for interfacing with scala.meta
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
macros
project
src
.gitignore
.travis.yml
LICENSE.md
README.md
build.sbt
publish

README.md

Eden Build Status

The dotty version of paradise to interface with scala.meta.

Usage

NOTE: Before the PR is merged into Dotty, the following instructions only make sense to our clone of the Dotty compiler. Check the build setting for the macros project for more details.

Command Line Usage

Download the latest assembly here, then compile with the assembly in class path:

./bin/dotc -classpath path/to/eden-assembly.jar macros.scala

Sbt Usage

Add Eden as a dependency:

libraryDependencies += "me.fengy" % "eden_2.11" % "0.1.2"

Macros

More examples can be found below:

Note: macro definitions have to be compiled before usage.

Annotation Macros

Definition:

import scala.annotation.StaticAnnotation
import scala.meta._
import scala.meta.dialects.Dotty

import scala.collection.immutable.Seq

class main extends StaticAnnotation {
  inline def apply(defn: Any): Any = meta {
    val q"object $name { ..$stats }" = defn
    val main = q"""
      def stub(args: Any): Any = { ..$stats }
    """
    q"object $name { $main }"
  }
}

Usage:

@main object Test {
  "hello world!"
}

Def Macros

Definition:

class plus {
  inline def apply(a: Any, b: Any): Any = meta {
    q"$a + $b"
  }
}

Usage:

val p = new plus
assert(p(3, 5) == 8)