{"id":16682175,"url":"https://github.com/luc-tielen/eclair-lang","last_synced_at":"2025-04-09T22:18:06.593Z","repository":{"id":37013742,"uuid":"378435456","full_name":"luc-tielen/eclair-lang","owner":"luc-tielen","description":"A minimal, fast Datalog implementation in Haskell that compiles to LLVM IR","archived":false,"fork":false,"pushed_at":"2024-01-22T09:15:36.000Z","size":4080,"stargazers_count":222,"open_issues_count":9,"forks_count":13,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-09T22:18:01.734Z","etag":null,"topics":["compiler","datalog","haskell","llvm","logic-programming"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luc-tielen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"luc-tielen"}},"created_at":"2021-06-19T14:46:24.000Z","updated_at":"2025-03-24T07:13:25.000Z","dependencies_parsed_at":"2023-10-05T00:46:18.924Z","dependency_job_id":"69767549-b861-427c-923e-435de08b6bcb","html_url":"https://github.com/luc-tielen/eclair-lang","commit_stats":{"total_commits":666,"total_committers":4,"mean_commits":166.5,"dds":0.07207207207207211,"last_synced_commit":"5254a56ef14ef8a4c6a22dbd4f6110304ff47db9"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luc-tielen%2Feclair-lang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luc-tielen%2Feclair-lang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luc-tielen%2Feclair-lang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luc-tielen%2Feclair-lang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luc-tielen","download_url":"https://codeload.github.com/luc-tielen/eclair-lang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119286,"owners_count":21050755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","datalog","haskell","llvm","logic-programming"],"created_at":"2024-10-12T14:06:27.348Z","updated_at":"2025-04-09T22:18:06.571Z","avatar_url":"https://github.com/luc-tielen.png","language":"Haskell","funding_links":["https://github.com/sponsors/luc-tielen"],"categories":[],"sub_categories":[],"readme":"\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"./logo_dark.png\"/\u003e\n  \u003cimg\n    src=\"./logo_light.png\"\n    alt=\"Logo for the Eclair programming language\"\n    loading=\"lazy\"\n    decoding=\"async\"/\u003e\n\u003c/picture\u003e\n\n_An experimental and minimal Datalog implementation that compiles down to LLVM._\n\n[![Build](https://github.com/luc-tielen/eclair-lang/actions/workflows/build.yml/badge.svg)](https://github.com/luc-tielen/eclair-lang/actions/workflows/build.yml)\n\n## Features\n\nEclair is a minimal Datalog (for now). It supports the following features:\n\n- Facts containing literals\n- Rules consisting of one or more clauses.\n- Rules can be non-recursive, recursive or mutually recursive.\n\nRight now it compiles to LLVM but be aware there might still be bugs. \nSome edge cases might not be handled yet.\n\n## Motivating example\n\nLet's say we want to find out which points are reachable in a graph. We can\ndetermine which points are reachable using the following two logical rules:\n\n1. One point is reachable from another point, iff there is a direct edge between\n   those two points.\n2. One point is reachable from another point, iff there is a third point 'z' such\n   that there is a direct edge between 'x' and 'z', and between 'z' and 'y'.\n\nThe Eclair code below can be used to calculate the solution:\n\n```eclair\n@def edge(u32, u32).\n@def reachable(u32, u32).\n\nreachable(x, y) :-\n  edge(x, y).\n\nreachable(x, z) :-\n  edge(x, y),\n  reachable(y, z).\n```\n\nThe above code can be compiled to LLVM using the Docker image provided by this repo:\n\n```bash\n$ git clone git@github.com:luc-tielen/eclair-lang.git\n$ cd eclair-lang\n$ docker build . -t eclair\n# The next line assumes the eclair code is saved as \"example.dl\" in the current directory\n$ docker run -v $PWD:/code --rm -it eclair:latest compile /code/example.dl\n# NOTE: output can be redirected to a file using standard shell functionality: docker run ... \u003e example.ll\n```\n\nThis will emit the generated LLVM IR to the stdout of the terminal. If we save\nthis generated LLVM IR to a file (e.g. `example.ll`), we can link it with the\nfollowing C code that calls into Eclair, using the following command:\n`clang -o program main.c example.ll`.\n\n```c\n// Save this file as \"main.c\".\n#include \u003cstdio.h\u003e\n#include \u003cstdlib.h\u003e\n#include \u003cstdbool.h\u003e\n#include \u003cstdint.h\u003e\n\n\nstruct program;\n\nextern struct program* eclair_program_init();\nextern void eclair_program_destroy(struct program*);\nextern void eclair_program_run(struct program*);\nextern void eclair_add_facts(struct program*, uint16_t fact_type, uint32_t* data, size_t fact_count);\nextern void eclair_add_fact(struct program*, uint16_t fact_type, uint32_t* data);\nextern uint32_t* eclair_get_facts(struct program*, uint16_t fact_type);\nextern void eclair_free_buffer(uint32_t* data);\n\nint main(int argc, char** argv)\n{\n    struct program* prog = eclair_program_init();\n\n    // edge(1,2), edge(2,3)\n    uint32_t data[] = {\n        1, 2,\n        2, 3\n    };\n    eclair_add_facts(prog, 0, data, 2);\n\n    eclair_program_run(prog);\n\n    // NOTE: normally you call btree_size here to figure out the size, but I know there are only 3 facts\n    uint32_t* data_out = eclair_get_facts(prog, 1);\n    printf(\"REACHABLE: (%d, %d)\\n\", data_out[0], data_out[1]);  // (1,2)\n    printf(\"REACHABLE: (%d, %d)\\n\", data_out[2], data_out[3]);  // (2,3)\n    printf(\"REACHABLE: (%d, %d)\\n\", data_out[4], data_out[5]);  // (1,3)\n\n    eclair_free_buffer(data_out);\n\n    eclair_program_destroy(prog);\n    return 0;\n}\n```\n\nIf you run the resulting program, this should print the reachable node pairs\n`(1,2)`, `(2,3)` and `(1,3)` to the screen!\n\n## Roadmap\n\n- [x] LSP support\n- [x] Allow setting options on relations for performance finetuning\n- [x] Comparison operators, != operator\n- [x] Support arithmetic operators\n- [x] Generic, extensible primops\n- [x] Support logical negation\n- [ ] Release 0.2.0\n- [ ] Signed integer type (i32)\n- [ ] Unary negation\n- [ ] Optimizations on the AST / RA / LLVM level\n- [ ] Support other underlying data structures than btree\n- [ ] Syntactic sugar (disjunctions in rule bodies, multiple rule heads, ...)\n- [ ] Support Datalog programs spanning multiple files\n- [ ] ...\n\nThis roadmap is not set in stone, but it gives an idea on the direction of the\nproject. :smile:\n\n## Contributing to Eclair\n\nContributions are welcome! Take a look at the\n[getting started guide](./docs/getting_started.md) on how to set up your machine\nto build, run and test the project. Once setup, the Makefile contains the most\ncommonly used commands needed during development.\n\nYou can also use the `Dockerfile` in this repository if you want to experiment\nwith Eclair without installing the toolchain yourself. You can do that as\nfollows:\n\n```bash\n$ docker build -f Dockerfile . -t eclair\n$ touch test.eclair  # Here you can put your Eclair code\n$ docker run -v $PWD:/code --rm -it eclair eclair compile /code/test.eclair\n```\n\n## Documentation\n\nTake a look at our [docs folder](./docs/) for more information about Eclair.\n\n## Why the name?\n\nEclair is inspired by [Soufflé](https://souffle-lang.github.io/), a high\nperformance Datalog that compiles to C++. Because of the similarities, I chose a\ndifferent kind of food that I like. I mean, an eclair contains _both_ chocolate and\npudding, what's not to like!?\n\nLogo art by [Bruno Monts](https://www.instagram.com/bruno_monts/),\nwith special thanks to the [Fission](https://fission.codes) team.\nPlease contact Luc Tielen before using the logo for anything.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluc-tielen%2Feclair-lang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluc-tielen%2Feclair-lang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluc-tielen%2Feclair-lang/lists"}