FunnyQT

Period: Dec 01, 2013 - Nov 30, 2015
Status: laufend

The FunnyQT project aim as defining and implementing a comprehensive model querying and transformation approach.

FunnyQT is not a new querying and transformation language with its own syntax and semantics, but instead it is implemented as an API for the functional, JVM-based Lisp dialect Clojure.  Thus, queries and transformations are Clojure programs that use the functions and constructs provided by the FunnyQT API.

By using an API-based approach embedded in a functional programming language, its features like functions as first-class objects, higher-order functions, lazy sequencen, and lexical closures can be exploited for the sake of model querying and transformation.  Furthermore, arbitrary third-party Clojure and Java libraries may be used.  Hence, it is possible to define transformations which query and modify not only models but arbitrary structured data that is programmatically accessible (e.g., databases, XML documents).

As a Lisp dialect, Clojure offers strong metaprogramming capabilities allowing to define macros which are a kind of transformation on the abstract syntax trees of Clojure programs.  This language feature allows for defining embedded domain-specific languages (DSLs), and FunnyQT uses it extensively to provide adequate and concise constructs to query and transformation developers. The goal is to give developers the feel of using a specialized query and transformation language rather than only an API in a general purpose programming language, e.g., transformation specifications must only deal with transformation logic without any boilerplate code.

FunnyQT supports as model representation both JGraLab TGraphs and EMF models (Eclipse Modeling Framework).  It should be noted that FunnyQT uses the models in their native representations, i.e., there is no intermediate representation used internally.  FunnyQT is designed as being extensible, so support for other model representations can be added without the need of changing its internals.

As a comprehensive querying and transformation approach, FunnyQT provides (or will eventually provide) the following features (provided as sub-APIs/namespaces):

  • The core is defined by a sub-API for model management including functions for creating, loading, and saving of models and metamodels, functions for creating and deleting model elements, functions for accessing properties of model elements, and functions for iterating and navigating model elements. The core consists of framework-specific sub-APIs (one for JGraLab, one for EMF) giving access to all properties provided by the respective framework, and a generic sub-API abstracting from the concrete frameworks and giving access to the common concepts.
  • Built upon the core API, there is an efficient and expressive querying API which provides constructs like comprehensions, quantified expressions, and a variation of GReQL's regular path expressions.
  • There is a pattern matching API which allows to define patterns in terms of typed node and edge symbols and additional constraints.  The application of a pattern to a model results in the lazy sequence of matches.  Every match contains model elements for which a homomorphic mapping from pattern symbols to model elements satisfying typing and additional constraints exist.
  • Built upon the pattern matching API there is an in-place transformation API allowing the definition of in-place transformation rules.  Every rule consists of a pattern and arbitrary many actions.  When a rule is invoked, a match is retrieved form the model and the actions are applied to it.  Typical in-place transformation control structures like as-long-as-possible iteration are provided as higher-order functions.
  • There a two out-place transformation APIs supporting the generation of new target models from existing source models.  One API is based on the concepts of extensional semantics found in GReTL while the other API provides a rule-based means to unidirectional model transformations.
  • A relational querying API supports Prolog-like, logical model querying. Parametrized relations on models can be defined which are distinguished from functions in that every parameter may be both input and output.  If every parameter is already bound to a value (ground) when the relation is called, it acts as a predicate.  If there are unbound (fresh) parameters, all possible bindings which make the relation hold with respect to the queried model are enumerated.
  • Based on the relational querying API, there is a bidirectional model transformation API.  Such a transformation defines relations between a left and a right model.  For all elements in the left model satisfying a relation's constraints, there has to be at least one set of corresponding elements in the right model, and vice versa.  Such transformations can be used to generate a new right model given an existing left model, to generate a new left model given an existing right model, and to synchronize two existing models.
  • Lastly, a (TGraph-specific) sub-API allows for transforming metamodels and models in parallel at runtime.  The API provides CRUD operations for metamodel elements where the effect on the instance models can be defined as a function.  For example, it is possible to add a new attribute to some metamodel class, where the semantics on the instance models can be defined by a function assigning a value to existing elements of that class.

Funding

DFG-funded project (Fundingnumber EB119/10-1)

Literature

Publications

HTTP Error 404: Not Found