Code Monkey home page Code Monkey logo

efftp's Introduction

Effects Plugin for Scala

This repo holds the source of a Scala compiler plugin for effect checking. For documentation refer to the Wiki on Gihub.

Scala Version

The master branch of this repository builds against Scala 2.10.1.

In the upcoming Scala 2.11 (the master branch of the the scala/scala repository), templates and constructors have a slightly different tree representation. The scala-2.11 should take that into account (it is not up to date though, the main branch might not merge cleanly into it, and it's not tested)

Building

Just run sbt package. The resulting target/scala-2.10/effects-plugin_2.10-0.1-SNAPSHOT.jar file is a compiler plugin that can be used with the Scala 2.10.1 compiler (the Wiki explains how).

Running the Tests

The tests for the plugin are in a separate sbt project: the reason is that we first need to build the compiler plugin (done in sbt project effects-plugin) and then run the tests using the plugin .jar file (sbt project tests).

Therefore, use the sbt command tests/test to run the tests. For details on the testing framework check the Wiki.

Screenshot

Eclipse Screenshot

Compiler Output

tsf-444-wpa-1-227:src luc$ ~/scala/scala-2.10.1/bin/scalac -P:effects:domains:purity:exceptions:io -Xplugin:/Users/luc/scala/efftp/target/scala-2.10/effects-plugin_2.10-0.1-SNAPSHOT.jar -cp /Users/luc/scala/efftp/target/scala-2.10/effects-plugin_2.10-0.1-SNAPSHOT.jar T.scala 
T.scala:10: error: effect type mismatch;
 found   : @io
 required: @noIo
    println()
           ^
T.scala:18: error: effect type mismatch;
 found   : @mod(C.this) @loc(any)
 required: @mod(x$1$2) @assign(x$1$2,any) @loc(any)
@mod(C.this) does not conform to @mod(x$1$2)
  def incBad(): Unit @mod() = x = x + 1
                                ^
T.scala:24: error: effect type mismatch;
 found   : @mod() @loc() @throws[C.this.E1] @noIo
 required: @mod(any) @assign(any) @loc(any) @throws[Nothing] @io
@throws[C.this.E1] does not conform to @throws[Nothing]
  def bad(): Int @throws[Nothing] = throw new E1
                                    ^
three errors found

More Examples

Have a look at the tests. The most enlightening test is probably the one on collections.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.