Compiler plugin goodies for Scala (continuation of non-OpenCL part of ScalaCL)
Scala JavaScript Other
Latest commit d0678d7 Apr 9, 2015 @ochafik ochafik Update README.md
Failed to load latest commit information.
Beans Scala 2.11.6 is upon us! Mar 26, 2015
CasbahDSL/src Use IntelliJ sbt plugin Oct 18, 2014
Components/src Fix random 2.11 warnings Mar 26, 2015
DSL less warnings Jun 9, 2014
Enum less warnings Jun 9, 2014
Experiments Dump local Scala -> Java8 lambdas conversion experiment Mar 26, 2015
Fx Update README.md Apr 9, 2015
Generic Generic: moved to http://github.com/nativelibs4java/scalaxy-generic Apr 7, 2015
Integration/src/test/scala drop lingering scalaxy-assert imports Mar 20, 2015
JSON Scala 2.11.6 is upon us! Mar 26, 2015
Loops-2.10 Fix random 2.11 warnings Mar 26, 2015
Loops Scala 2.11.6 is upon us! Mar 26, 2015
Obsolete Fix random 2.11 warnings Mar 26, 2015
Parano Parano: moved to http://github.com/nativelibs4java/scalaxy-parano Apr 7, 2015
Privacy Privacy: Readme Mar 26, 2015
Reified Reified: moved to http://github.com/nativelibs4java/scalaxy-reified Apr 7, 2015
Streams OMG: Scalaxy/Streams moved to https://github.com/nativelibs4java/scal… Mar 23, 2015
Union Updates for 2.11. Jun 29, 2014
project Drop streams, reified, parano, generic from build file now that they'… Apr 7, 2015
src/main/ls Updates for 2.11. Jun 29, 2014
.gitignore Dump JavaScript / ES6 diagrammed assertions experiment Mar 26, 2015
.jvmopts JVM opts for Travis CI (currently runs out of memory) Mar 19, 2015
.travis.yml simpler travis config Apr 7, 2015
IDEAS rehabilitated kepler version to top-level Aug 22, 2012
LICENSE readme Mar 24, 2015
README.md Update README.md Apr 7, 2015
release.sh OMG: Scalaxy/Streams moved to https://github.com/nativelibs4java/scal… Mar 23, 2015

README.md

Collection of Scala Macro goodies (BSD-licensed)

  • Streams (MIGRATED TO ITS OWN REPO) 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) }
  • 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)

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

  • Parano (MIGRATED TO ITS OWN REPO) 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 (MIGRATED TO ITS OWN REPO) 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 = reified((x: Int) => capture1 + capture2(x))
      val g = reified((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.

    • Debug (ScalaDoc) provides assert, require and assume macros that automatically add a useful message to the regular Predef calls. Please prefer Assertions and DiagrammedAssertions from ScalaTest.

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