Home

Awesome

SI-2712-fix plugin

This project fixes SI-2712 as a compiler plugin for Scala 2.10.x. This fix is in the compiler proper for Scala 2.11.x and Scala 2.12.x - see the Usage section for details.

The implementation is based on a simple algorithm as suggested by Paul Chiusano in the comments on SI-2712: Treat the type constructor as curried and partially applied, we treat a prefix as constants and solve for the suffix. For the example in the ticket, unifying M[A] with Int => Int, this unifies as,

M[t] = [t][Int => t]
A = Int

More detailed explanations can also be found at this gist Explaining Miles's Magic by @djspiewak and the readme of the demo project.

One place to discuss this fix is at typelevel's gitter room.

Usage

NOTE: This plugin should only be used by users still on Scala 2.10.x.

For Scala 2.11.x and 2.12.x users, the fix is available under the -Ypartial-unification compiler flag.

scalacOptions += "-Ypartial-unification"

Scala 2.12.x users can simply turn on the flag to enable the fix. Scala 2.11.x users can use Typelevel Scala with the same flag, or wait for Scala 2.11.9 which has the backport.

Scala 2.10.7 users can add the plugin by adding the following to their SBT build (no compiler flag needed):

addCompilerPlugin("com.milessabin" % "si2712fix-plugin_2.10.7" % "1.2.0")

// or
libraryDependencies += compilerPlugin("com.milessabin" % "si2712fix-plugin_2.10.7" % "1.2.0")

Examples

An example project can be found at milessabin/si2712fix-demo

Projects that use this plugin

Participation

This project supports the Typelevel code of conduct and wants all of its channels (Gitter, github, etc.) to be welcoming environments for everyone.

Building the plugin

This plugin is built with SBT 0.13.11 or later, and its master branch is built with Scala 2.11.8 and 2.10.7 by default.

Contributors