Code Monkey home page Code Monkey logo

squid's Introduction

Squid ― Scala Quoted DSLs

Join the chat at https://gitter.im/epfldata-squid/Lobby

Introduction

Squid (for the approximative contraction of Scala Quoted DSLs) is a metaprogramming framework that facilitates the type-safe manipulation of Scala programs. Squid is geared towards the implementation of library-defined optimizations [2] and helps with the compilation of Domain-Specific Languages (DSL) embedded in Scala [1]. In addition, it has an advanced static typing capabilities that reduce common metaprogramming errors [3].

Caution: Squid is still experimental, and the interfaces it exposes may change in the future (especially the semi-internal interfaces used to implement intermediate representation backends).

Installation

Squid currently supports Scala versions 2.11.3 to 2.11.11 (more recent versions might work as well, but have not yet been tested).

The project is not yet published on Maven, so in order to use it you'll have to clone this repository and publish Squid locally, which can be done by executing the script in bin/publishLocal.sh.

In your project, add the following to your build.sbt:

libraryDependencies += "ch.epfl.data" %% "squid" % "0.2-SNAPSHOT"

Some features related to library-defined optimizations and squid macros, such as @embed and @macroDef, require the use of the macro-paradise plugin. To use these features, add the following to your build.sbt:

val paradiseVersion = "2.1.0"

autoCompilerPlugins := true

addCompilerPlugin("org.scalamacros" % "paradise" % paradiseVersion cross CrossVersion.full)

Overview of Features

Squid Quasiquotes

Quasiquotes are the primitive tool that Squid provides to manipulate program fragments –– building, composing and decomposing them. Quasiquotes are central to most aspects of program transformation in Squid.

Type-Safe Code Manipulation

Unlike the standard Scala Reflection quasiquotes, Squid quasiquotes are statically-typed and hygienic, ensuring that manipulated programs remain well-typed and that variable bindings and other symbols do not get mixed up. Squid quasiquotes focus on expressions (not definitions), but Squid provides way to embed arbitrary class and object definitions so that their methods can be inlined at any point (or even automatically).

Flavors of Quasiquotes

Two forms of quasiquotes co-exist in Squid:

  • Simple Quasiquotes (tutorial) provide the basic functionalities expected from statically-typed quasiquotes, and can be used for a wide range of tasks, including multi-stage programming (MSP). They support both runtime interpretation, runtime compilation and static code generation. For more information, see [1].

  • Contextual Quasiquotes (tutorial) push the type-safety guarantees already offered by simple quasiquotes even further, making sure that all generated programs are well-scoped in addition to being well-typed. While they are slightly less ergonomic than the previous flavor, these quasiquotes are especially well-suited for expressing advanced program transformation algorithms and complicated staging techniques. For more information, see [3].

Both forms of quasiquotes support a flexible pattern-matching syntax and facilities to traverse programs recursively while applying transformations.

As a quick reference available to all Squid users, we provide a cheat sheet that summarizes the features of each system. Also see the quasiquotes tutorial.

TODO

Link to transformers documentation.

TODO

Link to IR documentation

TODO

TODO

Applications of Squid

Squid is new. See the examples folder for examples. A little query compiler built with Squid can be found here. Another LINQ-inspired query engine build with Squid can be found here.

Publications

[1]: Lionel Parreaux, Amir Shaikhha, and Christoph E. Koch. 2017. Squid: Type-Safe, Hygienic, and Reusable Quasiquotes. In Proceedings of the 2017 8th ACM SIGPLAN Symposium on Scala (SCALA 2017).
(Get the paper here.)

[2]: Lionel Parreaux, Amir Shaikhha, and Christoph E. Koch. 2017. Quoted Staged Rewriting: a Practical Approach to Library-Defined Optimizations. In Proceedings of the 2017 ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences (GPCE 2017). Best Paper Award. (Get the paper here.)

[3]: Lionel Parreaux, Antoine Voizard, Amir Shaikhha, and Christoph E. Koch. Unifying Analytic and Statically-Typed Quasiquotes. To appear in Proc. POPL 2018.

squid's People

Contributors

amirsh avatar christophkoch avatar fschueler avatar gitter-badger avatar lptk avatar sachinbjohn avatar

Watchers

 avatar  avatar

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.