All Projects → statebox → Cql

statebox / Cql

Licence: agpl-3.0
CQL: Categorical Query Language implementation in Haskell

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to Cql

Ltupatternfactory
Lambda the ultimate Pattern Factory: FP, Haskell, Typeclassopedia vs Software Design Patterns
Stars: ✭ 735 (+456.82%)
Mutual labels:  category-theory
Rapidql
Query multiple APIs and DBs and join them in a single query
Stars: ✭ 91 (-31.06%)
Mutual labels:  query-language
Hypergraphql
GraphQL interface for querying and serving linked data on the Web.
Stars: ✭ 120 (-9.09%)
Mutual labels:  query-language
Restql Http
Microservice query language
Stars: ✭ 793 (+500.76%)
Mutual labels:  query-language
Unplugged
Open book about math and computer science.
Stars: ✭ 1,189 (+800.76%)
Mutual labels:  category-theory
Tikzcd Editor
A simple visual editor for creating commutative diagrams.
Stars: ✭ 1,627 (+1132.58%)
Mutual labels:  category-theory
Neo4j Python Driver
Neo4j Bolt driver for Python
Stars: ✭ 607 (+359.85%)
Mutual labels:  query-language
Quiver
A modern commutative diagram editor for the web.
Stars: ✭ 1,799 (+1262.88%)
Mutual labels:  category-theory
Fundamental Haskell
Fundamental Haskell book, to the point terse statements on Haskell, Category theory, and related fields. Encyclopedic pocketbook of meaning. Zen kōan-like meditations of understanding. For quick or memory curve spaced repetition learning.
Stars: ✭ 88 (-33.33%)
Mutual labels:  category-theory
Groq
Specification for GROQ - Graph-Relational Object Queries
Stars: ✭ 117 (-11.36%)
Mutual labels:  query-language
Purescript Ctprelude
A Prelude with names from category theory
Stars: ✭ 46 (-65.15%)
Mutual labels:  category-theory
Purescript Selda
A type-safe, high-level SQL library for PureScript
Stars: ✭ 72 (-45.45%)
Mutual labels:  query-language
Pgql Lang
PGQL is an SQL-based query language for the Property Graph data model
Stars: ✭ 114 (-13.64%)
Mutual labels:  query-language
Fp Core.rs
A library for functional programming in Rust
Stars: ✭ 772 (+484.85%)
Mutual labels:  category-theory
Ldflex
A JavaScript DSL for querying Linked Data on the Web
Stars: ✭ 123 (-6.82%)
Mutual labels:  query-language
Eliasdb
EliasDB a graph-based database.
Stars: ✭ 611 (+362.88%)
Mutual labels:  query-language
Hypergraphql
GraphQL interface for querying and serving linked data on the Web.
Stars: ✭ 112 (-15.15%)
Mutual labels:  query-language
Naive functional programming
A naive approach to functional programming using TypeScript
Stars: ✭ 129 (-2.27%)
Mutual labels:  category-theory
Domains
A computational algebra system in Smalltalk.
Stars: ✭ 124 (-6.06%)
Mutual labels:  category-theory
Foundational Knowledge For Programmers
List of resources about foundational knowledge for programmers (supposed to last a few decades)
Stars: ✭ 115 (-12.88%)
Mutual labels:  category-theory

CQL

Build Status License: AGPL v3

Categorical Query Language (CQL) implementation in Haskell.

About

CQL 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 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 in collaboration with Conexus, who develop the Java version of CQL.

Learn more.

Example

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

# 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

The package can be built/tested/installed the following ways.

Stack

Build:

stack build

Test:

stack test

Install:

stack install

Generate docs:

stack haddock cql

Cabal

Generate .cabal file:

hpack

Build:

cabal build

Test:

cabal test

Install:

cabal install

Nix

Build & test:

nix-build

Install in current profile:

nix-env -f . -i

See also default.nix

HTTP API

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/cql \
  -H 'Content-Type: text/plain;charset=utf-8' \
  --data-binary "@./examples/Employee.cql"

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

  • 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].