A next-gen functional language
Go to file
Victor Taelin f9a5bdb963 mixed checking order for better unification
on the `infer` function, we usually have something like this:

    infer (App f x) ctx =
      infer <- infer f ctx
      case infer of
        All a b -> do
          check x a ctx
          return $ out arg
        otherwise ->
          fail

this causes `x : a` to be happen before `infer (f x)` returns `b x`.
this is generally fine, but, in situations such as dependent
eliminations:

    λx (bool-elim ?A x t f) : (P x)

we really want `(elim ...)` to return `P x` BEFORE we check `t : ?A
true` and `t : ?A false`. that would allow the unification problem `?A x
== P x` to generate the solution `?A = λx (P x)` **before** the `t : ?A
true` check possibly fails.

being able to fill that metavar is very important for Kind2, since that
would allow us to omit motives in pattern-matches. because of that, I
think that the more sensible order is for infer to return its result
first, and then its inner checks occur. this is via a very lightweight
mechanism that consists of a list of suspended checks (`susp`), which we
push to inside `infer`, and fully consume inside `check`.

this is a middle-ground between checking in order (from left-to-right)
and a more complex suspension mechanism (involving dependency graphs).
with this simple solution, we're able to use metavars inside the motive
of dependent eliminations, greatly reducing the need for annotations in
practical code.
2024-03-06 22:29:33 -03:00
book mixed checking order for better unification 2024-03-06 22:29:33 -03:00
docs typo 2024-02-25 20:53:25 -03:00
src mixed checking order for better unification 2024-03-06 22:29:33 -03:00
.gitignore auto formatter 2024-03-01 20:40:31 -03:00
Cargo.lock reorganize repo, split files 2024-03-01 14:30:11 -03:00
Cargo.toml reorganize repo, split files 2024-03-01 14:30:11 -03:00
kind2.ts Working Rust CLI! Pretty errors. Many improvements 2024-02-24 20:50:01 -03:00
package.json giving up on bootstrapping due to parser perf 2024-02-23 14:28:04 -03:00
README.md add usage notes 2024-02-08 20:04:56 -03:00

Kind2 WIP

Kind1 has been developed in JavaScript, which wasn't meant to be a long-term solution, but allowed us to explore self-types. Recently, we started developing Kind2 for HVM1, but it has been discontinued when we started working on HVM2. In this repository, we'll remake and continue Kind2's development, now targetting HVM2. Kind2 will be fully implemented in itself. Temporarily, we're using TypeScript+HVM1 to aid on the bootstrapping process.

Usage

  1. Install NPM.

  2. Install HVM1.

  3. Install Kind2: npm i -g (from this directory)

  4. Enter book/ and run with kind2 [check|run] term_name.