Skip to content

Commit

Permalink
Merge branch 'master' into ryan4-merge-attempt-2
Browse files Browse the repository at this point in the history
  • Loading branch information
epost committed Aug 5, 2019
2 parents 192c8e7 + 99cada6 commit c7257bf
Show file tree
Hide file tree
Showing 54 changed files with 1,871 additions and 288 deletions.
21 changes: 20 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# SPDX-License-Identifier: AGPL-3.0-only
#
# This file is part of `statebox/cql`, the categorical query language.
#
# Copyright (C) 2019 Stichting Statebox <https://statebox.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# see https://EditorConfig.org

# top-most EditorConfig file
Expand All @@ -10,4 +29,4 @@ end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
indent_size = 2
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.stack-work/
aql.cabal
http/aql-http.cabal
cql.cabal
http/cql-http.cabal
*~
.DS_Store
*.yaml#
*.aql#
*.cql#

1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
To get started, <a href="https://www.clahub.com/agreements/statebox/cql">sign the Contributor License Agreement</a>.
661 changes: 661 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

124 changes: 112 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,108 @@
[![Build Status](https://travis-ci.com/statebox/aql.svg?branch=master&token=Ljpteop2x6Z8X4NsFyyn)](https://travis-ci.com/statebox/aql)
# CQL

# AQL
[![Build Status](https://travis-ci.com/statebox/cql.svg?branch=master&token=Ljpteop2x6Z8X4NsFyyn)](https://travis-ci.com/statebox/cql)
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)

Algebraic Query Language implementation in Haskell.
Categorical Query Language (CQL) implementation in Haskell.

## Documentation

Paper describing how AQL is implemented: https://arxiv.org/abs/1503.03571
AQL user manual: https://categoricaldata.net/aqlmanual.pdf
Java version: https://github.com/CategoricalData/fql
## About

[CQL](https://www.categoricaldata.net) is a functional query language that allows you to specify data migrations declaratively, in a way that guarantees their correctness.

It is the culmination of years of original mathematical [research](https://www.categoricaldata.net/papers) after the right balance between flexibility and correctness. Its solid grounding in category theory sets it apart from its ad hoc counterparts, and enables the compositional development and analysis of data transformations to a degree previously impossible.

CQL, formerly known as AQL, was developed by [Statebox](https://www.statebox.org) in collaboration with [Conexus](http://conexus.ai/), who develop the [Java version](https://github.com/CategoricalData/cql) of CQL.

[Learn more](https://www.categoricaldata.net).

## Example

After building, you can use `cql` to evaluate a `.cql` file, e.g.

```sh
# build it
stack build

# run `cql` on `examples/Employee.cql`
stack exec cql examples/Employee.cql
```

Here is an example of what a `.cql` file looks like:

```
options
program_allow_nontermination_unsafe = true
allow_empty_sorts_unsafe = true
typeside T = literal {
types
string
nat
constants
Al Akin Bob Bo Carl Cork Dan Dunn Math CS : string
zero : nat
functions
succ : nat -> nat
plus : nat, nat -> nat
}
schema S = literal : T {
entities
Employee
Department
foreign_keys
manager : Employee -> Employee
worksIn : Employee -> Department
secretary : Department -> Employee
attributes
first last : Employee -> string
age : Employee -> nat
name : Department -> string
}
instance I = literal : S {
generators
a b : Employee
equations
a.manager = a
a.worksIn.secretary = a
b.manager = a
b.worksIn = a.worksIn
last(b) = Bo
multi_equations
first -> {a Al, b Bob}
}
instance J = literal : S {
generators
a b : Employee
c d : Department
y : nat
equations
a.manager = a
a.worksIn = d
c.secretary = b
b.manager = a
b.worksIn = c
d.secretary = b
first(a) = Al
a.last = Al
d.name = Bob
c.name = Al
age(a) = zero
age(b) = y
options interpret_as_algebra = true
}
```

## Building

Expand All @@ -30,7 +124,7 @@ Install:

Generate docs:

`stack haddock aql`
`stack haddock cql`

### Cabal

Expand Down Expand Up @@ -64,19 +158,25 @@ See also [default.nix](default.nix)

## HTTP API

To launch the APIs, use `stack exec aql-http`. Then you can send http requests to port 8080, with an AQL specification in the body. The `Content-Type` of the request needs to be set to `text/plain;charset=utf-8`
To launch the APIs, use `stack exec cql-http`. Then you can send http requests to port 8080, with an CQL specification in the body. The `Content-Type` of the request needs to be set to `text/plain;charset=utf-8`

For example, you could try using `cURL` as follows

```
curl -X POST \
http://localhost:8080/aql \
http://localhost:8080/cql \
-H 'Content-Type: text/plain;charset=utf-8' \
--data-binary "@./examples/Employee.aql"
--data-binary "@./examples/Employee.cql"
```

You can set the following environment variables to customise the behaviour of the endpoint:

- `AQL_ENV`: Should be `Development` or `Production`. Regulates the verbosity of the console output.
- `CQL_ENV`: Should be `Development` or `Production`. Regulates the verbosity of the console output.

- `PORT`: determines on which port the endpoint is exposed

### License

Unless explicitly stated otherwise all files in this repository are licensed under the GNU Affero General Public License.

Copyright © 2019 [Stichting Statebox](https://statebox.nl).
33 changes: 0 additions & 33 deletions aql.nix

This file was deleted.

22 changes: 21 additions & 1 deletion cli/Main.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
{-
SPDX-License-Identifier: AGPL-3.0-only
This file is part of `statebox/cql`, the categorical query language.
Copyright (C) 2019 Stichting Statebox <https://statebox.nl>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-}
module Main where

import Language.AQL
import Language.CQL
import System.Environment


Expand Down
54 changes: 54 additions & 0 deletions cql.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
SPDX-License-Identifier: AGPL-3.0-only
This file is part of `statebox/cql`, the categorical query language.
Copyright (C) 2019 Stichting Statebox <https://statebox.nl>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

{ mkDerivation, stdenv, hpack, hspec
, base, containers, megaparsec, servant-server, term-rewriting, tabular, wai
, wai-extra, warp, twee-lib, union-find, fgl, mtl, PropLogic }:

mkDerivation {
pname = "cql";
version = "0.1.0.0";
src = ./.;

isLibrary = true;
isExecutable = true;
doCheck = true;

libraryHaskellDepends = [
base containers megaparsec servant-server term-rewriting tabular wai wai-extra
warp twee-lib union-find fgl mtl PropLogic
];
executableHaskellDepends = [
base megaparsec term-rewriting twee-lib containers union-find fgl mtl PropLogic
];
testHaskellDepends = [
base megaparsec term-rewriting hspec twee-lib containers union-find fgl mtl PropLogic
];
buildDepends = [ hpack ];

preConfigure = ''
hpack
'';

homepage = "https://github.com/statebox/cql";
description = "CQL - Categorical Query Language implementation in Haskell";
license = stdenv.lib.licenses.agpl3;
}
25 changes: 23 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
SPDX-License-Identifier: AGPL-3.0-only
This file is part of `statebox/cql`, the categorical query language.
Copyright (C) 2019 Stichting Statebox <https://statebox.nl>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

# Nix package for development
#
## INSTALL
Expand All @@ -16,7 +37,7 @@
#
# To launch a shell with all dependencies installed in the environment:
#
# $ nix-shell -A aql
# $ nix-shell -A cql
#
# After entering nix-shell, build it:
#
Expand Down Expand Up @@ -61,5 +82,5 @@ let
stdenv = usepkgs.stdenvAdapters.keepDebugInfo usepkgs.stdenv;

in {
aql = usepkgs.haskellPackages.callPackage ./aql.nix { };
cql = usepkgs.haskellPackages.callPackage ./cql.nix { };
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/Mapping.aql → examples/Mapping.cql
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ transform h = literal : I -> I {
}

mapping m2 = [ M ; M ]
transform h2 = [ h ; h ]
transform h2 = [ h ; h ]
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/Timeout.aql → examples/Timeout.cql
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ schema S = literal : empty {
instance I = literal : S {
generators e : E
options timeout = "1"
}
}
20 changes: 20 additions & 0 deletions http/Main.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
{-
SPDX-License-Identifier: AGPL-3.0-only
This file is part of `statebox/cql`, the categorical query language.
Copyright (C) 2019 Stichting Statebox <https://statebox.nl>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-}
module Main where

import Api.App (app)
Expand Down
Loading

0 comments on commit c7257bf

Please sign in to comment.