What does HackerNews think of chalk?

An implementation and definition of the Rust trait system using a PROLOG-like logic solver

Language: Rust

The Rust compiler uses a Prolog-like query language internally for type checking generic requirements and traits: https://github.com/rust-lang/chalk
> Not all of those things work well in the real world. E.g. logic programming (prolog) is cool but ultimately never really caught on.

It does have its niches though. For example, there is a trait solver for Rust called Chalk that uses a Prolog-inspired language because trait bounds basically define a logic:

https://github.com/rust-lang/chalk

RA uses chalk [1], which is a trait solver rewrite for rustc. You can already use it on nightly with a feature flag.

So RA can get close to the trait resolution of the compiler, which is probably the most challenging part. I haven't used Intellij in a while, but I doubt they can ever get close with their custom implementation. I always had trouble with trait resolution/autocompletion, which is often where you need from the IDE the most.

[1] https://github.com/rust-lang/chalk

I didn't mean to imply that it was impossible.

You would know better of course, but it was my impression that there is no firm commitment to stabilizing GAT, even once the compiler fully switches to Chalk, due the potential disruptiveness and complication of the language.

(For those unaware: Chalk is a rewrite of the trait logic in rustc, based on logic programming [1] )

[1] https://github.com/rust-lang/chalk

It is also integesting to see how typeclasses/traits and OCaml's (still upcoming?) "modular implicits" are related to logic programming.

I commend the rustc team for taking this lineage seriously in developing Chalk[1] and using differential-dataflow for the next borrow checker. If they combine those into a differential-dataflow-powered Chalk it will be very formidable!

We'll have to catch up Haskell at some point, sigh.

[1]: https://github.com/rust-lang/chalk.git

[2]: https://github.com/TimelyDataflow/differential-dataflow

In the Rust ecosystem, I believe the next-generation IDE support is already beginning to incorporate some ideas like this, although I believe it uses Prolog rather than Datalog (I'd be interested to learn more about how they differ). The logic library is called Chalk ( https://github.com/rust-lang/chalk ), and it's designed to be a full trait resolution engine for Rust (trait resolution being a necessary step to e.g. autocomplete methods on types); rust-analyzer has been using it for quite a while now, and it's slowly being incorporated into rustc itself. Not as impressive as basing the entire IDE on queries, of course!

The Rust project is also using the differential-datalog library mentioned in the OP to underlie their third-generation borrow checker: https://github.com/rust-lang/polonius

Using a Prolog implementation behind Rust Analyzer is very interesting, here is the post announcing it: http://smallcultfollowing.com/babysteps/blog/2017/01/26/lowe... and more info here: https://github.com/rust-lang/chalk
A tangeant question is: Which non-niche language are having push for integrating a subset of logic programming extensions ?

There was a (unlikely to be merged at least in its current form) proposal for Kotlin -> https://github.com/Kotlin/KEEP/pull/199/files

Maybe LINQ from .NET could be included

There is also chalk from Rust https://github.com/rust-lang/chalk

Fun fact: Niko Matsakis is working on a rewrite of Rust's typechecking/trait matching infrastructure in Chalk, which is a derivative of Prolog: https://github.com/rust-lang/chalk

Prolog is surprisingly (or not surprisingly, given the Curry-Howard isomorphism) useful for implementation of programming languages, especially typecheckers.

Chalk is a PROLOG-ish interpreter written in Rust, intended eventually for use in the rustc compiler. Chalk recasts Rust's trait system in terms of logic programming. Its goal is to be an executable, highly readable specification of the Rust trait system.

https://github.com/rust-lang/chalk

https://rust-lang.github.io/rustc-guide/traits/chalk-overvie...