-
Notifications
You must be signed in to change notification settings - Fork 5
Obtaining and Running the Plugin
Since the plugin is still changing rapidly we don't provide a downloadable distribution. Instead, clone this repository and run sbt package. The file target/scala-2.10/effects-plugin_2.10-0.1-SNAPSHOT.jar is the compiler plugin.
To enable effect checking you need to pass the following options to the Scala compiler (command line, eclipse, sbt):
-Xplugin:<PLUGIN-CHECKOUT>/target/scala-2.10/effects-plugin_2.10-0.1-SNAPSHOT.jar
-cp <PLUGIN-CHECKOUT>/target/scala-2.10/effects-plugin_2.10-0.1-SNAPSHOT.jar
-P:effects:domains:<DOMAIN-LIST>
where <DOMAIN-LIST> is a :-separated list of effect domains, e.g. io or purity:exceptions:io.
The effect annotations are in package scala.annotation.effects in the plugin jar file (for that reason the plugin jar needs to be on the classpath). We recommend importing them as
import annotation.effects._Running the plugin in the REPL works, but you need to make sure you get all compiler options right.
tsf-444-wpa-2-149:scala-2.10 luc$ ~/scala/scala-2.10.1/bin/scala -cp effects-plugin_2.10-0.1-SNAPSHOT.jar -Xplugin:effects-plugin_2.10-0.1-SNAPSHOT.jar -P:effects:domains:io
Welcome to Scala version 2.10.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_45).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import annotation.effects._
import annotation.effects._
scala> def f: Int @io = 1
f: Int @scala.annotation.effects.io
scala> def g: Int @pure = if (f > 10) 0 else 1
<console>:11: error: effect type mismatch;
found : @io
required: @noIo
def g: Int @pure = if (f > 10) 0 else 1
^
Enabling the plugin in the presentation compiler in Eclipse enables immediate effect checking feedback:
