Java Middleware

We have developed a Java program between the JavaScript frontend and Haskell backend. Since there is no known method to integrate JavaScript and Haskell the way that the system requires, we developed this program. It uses Java Spring framework. It is responsible for various tasks:

  • the program starts the frontend and the backend,

  • it translates our multi-model query language into Haskell fold-functions,

  • it sends translated queries to the Haskell backend and parses the results,

  • it stores queries and results for possible later use.

The program contains a small JSONDB database that stores queries, parsed queries, and certain results. The Java program connects to Haskell backend using ProcessBuilder.

Query tokenizing, parsing and translating

Each selective query becomes an instance of a class called SelectiveQuery. When SelectiveQuery object is created, the input query string is automatically tokenized, parsed, and translated so that the user can output the corresponding Haskell code i.e. the sequence of fold functions. Each SelectiveQuery consists of one or multiple QueryBlocks which have one or multiple LambdaFunctions.

This structure of classes creates a simple parse tree of the query and it can be efficiently used to modify and understand the query. Certain keywords (cons, nil which are related to [Gru04] and [Gru99]) are modified with respect to the target model of the query and the correct fold function is used with respect to the target model of the query. The CodeGenerator class is partly responsible for this.