Skip to content
This repository

Compiler plugin goodies for Scala (continuation of non-OpenCL part of ScalaCL)

branch: master
Octocat-spinner-32 Beans Edit build files and readmes to require sbt 0.13.0 + Scala 2.10.3 October 22, 2013
Octocat-spinner-32 CasbahDSL misc changes February 23, 2014
Octocat-spinner-32 Components Components: no need for old symbol key hacks October 23, 2013
Octocat-spinner-32 DSL dumping experimental code for collection-like DSLs March 07, 2013
Octocat-spinner-32 Debug Edit build files and readmes to require sbt 0.13.0 + Scala 2.10.3 October 22, 2013
Octocat-spinner-32 Enum Enum: warnings-- October 07, 2013
Octocat-spinner-32 Experiments Scalaxy/JS: moved code around February 23, 2014
Octocat-spinner-32 Fx Update README.md October 25, 2013
Octocat-spinner-32 Generic Generic: GenericOps.toString calls directly value.toString October 07, 2013
Octocat-spinner-32 Integration Loops: filter vals to defs August 20, 2013
Octocat-spinner-32 JSON JSON: readme += error October 25, 2013
Octocat-spinner-32 Loops Scalaxy/Loops & Streams 0.1 Release for Scala 2.11.0-RC1 March 20, 2014
Octocat-spinner-32 Obsolete Update README.md October 23, 2013
Octocat-spinner-32 Parano Scalaxy/Privacy: batch flag tests February 23, 2014
Octocat-spinner-32 Privacy Privacy: fix handling of packages March 02, 2014
Octocat-spinner-32 Reified dummy reified test February 23, 2014
Octocat-spinner-32 Streams Scalaxy/Loops & Streams 0.1 Release for Scala 2.11.0-RC1 March 20, 2014
Octocat-spinner-32 Union Update README.md October 24, 2013
Octocat-spinner-32 project post release versions March 20, 2014
Octocat-spinner-32 src Reorganized dependencies, scalaxy-compilets now depends on scalaxy-pl… November 02, 2012
Octocat-spinner-32 .gitignore Scalaxy/Privacy: cleanup February 23, 2014
Octocat-spinner-32 IDEAS rehabilitated kepler version to top-level August 22, 2012
Octocat-spinner-32 LICENSE rehabilitated kepler version to top-level August 22, 2012
Octocat-spinner-32 README.md Scalaxy/Loops & Streams 0.1 Release for Scala 2.11.0-RC1 March 20, 2014
README.md

Collection of Scala Macro goodies (BSD-licensed)

  • Loops provide a macro that optimizes simple foreach loops on Ranges by rewriting them to equivalent while loops (Scala 2.10.x):

    import scalaxy.loops._
    
    for (i <- 0 until 100000000 optimized) { ... }
    

    (special case of / superseeded by Streams below)

  • Streams provide a macro and a compiler plugin that optimize streamed collection operations / for comprehensions by rewriting them to equivalent while loops (Scala 2.11.x):

    for (i <- 0 to n;
         ii = i * i;
         j <- i to n;
         jj = j * j;
         if (ii - jj) % 2 == 0;
         k <- (i + j) to n)
      yield { (ii, jj, k) }
    
  • Debug (ScalaDoc) provides assert, require and assume macros that automatically add a useful message to the regular Predef calls.

  • JSON (ScalaDoc) provides macro-based json string interpolation with smart error reporting, compile-time renormalization, deconstruction and more.

  • Parano provides compile-time checks to avoid common naming mistakes (ambiguous or swapped case class field extractor names, ambiguous unnamed param names with same type...)

  • Privacy changes the default member visibily from public to private (unless the @public annotation is used)

  • Beans (ScalaDoc) are a nifty combination of Dynamics and macros that provide a type-safe eye-candy syntax to set fields of regular Java Beans in a Scala way (without any runtime dependency at all!):

    import scalaxy.beans._
    
    new MyBean().set(foo = 10, bar = 12)
    
  • Fx (ScalaDoc) contains an experimental JavaFX DSL (with no runtime dependency) that makes it easy to build objects and define event handlers:

    new Button().set(
      text = bind {
        s"Hello, ${textField.getText}"
      },
      onAction = {
        println("Hello World!")
      }
    )
    
  • Reified (ScalaDoc) provides a powerful reified values mechanism that deals well with composition and captures of runtime values, allowing for complex ASTs to be generated during runtime for re-compilation or transformation purposes. It preserves the original value that was reified, allowing for flexible mixed usage of runtime value and compile-time AST.

    import scalaxy.reified._
    
    def comp(capture1: Int): ReifiedFunction1[Int, Int] = {
      val capture2 = Seq(10, 20, 30)
      val f = reify((x: Int) => capture1 + capture2(x))
      val g = reify((x: Int) => x * x)
    
      g.compose(f)
    }
    
    println("AST: " + comp(10).expr().tree)
    
  • Obsolete experiments (mostly because of quasiquotes):

    • MacroExtensions provides an extremely simple (and experimental) syntax to define extensions methods as macros:

      @scalaxy.extension[Any] 
      def quoted(quote: String): String = 
        quote + self + quote
      
      @scalaxy.extension[Int] 
      def copiesOf[T : ClassTag](generator: => T): Array[T] = 
        Array.fill[T](self)(generator)
      
      ...
      println(10.quoted("'"))
      // macro-expanded to `"'" + 10 + "'"`
      
      println(3 copiesOf new Entity)
      // macro-expanded to `Array.fill(3)(new Entity)`
      
    • Compilets provide an easy way to express AST rewrites, backed by a compiler plugin and an sbt plugin.

Discuss

If you have suggestions / questions:

You can also file bugs and enhancement requests here.

Any help (testing, patches, bug reports) will be greatly appreciated!

Hacking

  • Pushing the site with each sub-project's Scaladoc at http://ochafik.github.io/Scalaxy/:

    sbt clean
    sbt "project scalaxy-doc" ghpages-push-site
    

    (you can preview the site with sbt "project scalaxy-doc" preview-site)

  • Publishing projects on Sonatype OSS Repository + advertise on ls.implicit.ly (assuming correct credentials in ~/.sbt/0.13/sonatype.sbt):

    sbt "+ assembly" "+ publish"
    sbt "project scalaxy" ls-write-version lsync
    
Something went wrong with that request. Please try again.