cooltt

repository·main·Indexed 42 days ago

https://github.com/redprl/cooltt

A research-oriented implementation of normalization by evaluation (NbE) and elaboration for Cartesian cubical type theory. A fork of blott incorporating code from redtt, it provides a CLI for elaborating and normalizing terms in both scripting and interactive REPL modes, along with a Vim plugin and Zsh completion support.

Tokens
1.5K
Snippets
8
Records
10
Agent score
54%

What's inside cooltt

  1. Configure cooltt for Zsh completion

    main

    To enable cooltt command completions in Zsh, you must add the cooltt/zsh directory to your $fpath and ensure compinit is called. Add the following lines to your ~/.zshrc file, replacing PATH-TO-COOLTT with the actual absolute path to the cooltt installation directory:

    fpath=(PATH-TO-COOLTT/zsh $fpath)
    compinit #if `compinit` would not be called by the end of your ~/.zshrc
  2. Install cooltt.vim

    main

    You can install or reinstall the plugin by running the install.sh script from the plugin directory. The plugin is compatible with Vim 8's package system.

    ./install.sh
  3. Install and build cooltt with OPAM

    main

    To build cooltt using OPAM, ensure you are using OCaml 5.0. You can create a compatible switch using opam switch create 5.0.0.

    Follow these steps to install dependencies and build the package:

    1. Update opam: opam update
    2. Pin the local directory: opam pin add -y cooltt . (only required the first time)
    3. Upgrade dependencies: opam upgrade

    If you are actively developing the project and using dune, use these commands to manage the environment:

    • make upgrade-pins: Updates and upgrades dependencies for active development.
    • dune exec cooltt: Runs the cooltt executable from the top-level directory.
    # Create OCaml 5.0 switch
    $ opam switch create 5.0.0
    
    # Install dependencies
    $ opam update
    $ opam pin add -y cooltt .
    $ opam upgrade
    
    # For active development
    $ make upgrade-pins
    $ dune exec cooltt
  4. Use the cooltt CLI

    main

    The cooltt command-line tool is used to elaborate and normalize terms in Cartesian cubical type theory. It supports two primary modes: scripting (default), where you provide a file or standard input to process, and interactive, which launches a REPL (Read-Eval-Print Loop).

    # Run in scripting mode on a specific file
    cooltt my_term.ctt
    
    # Run in interactive REPL mode
    cooltt --interactive
    
    # Run in scripting mode using standard input
    cat my_term.ctt | cooltt -
  5. Install and build cooltt with Nix

    main

    If you use the Nix package manager with flakes enabled, you can build or develop with cooltt using the following methods:

    To build the binary: Run nix build. This will place the cooltt binary in result/bin/cooltt.

    To enter a development environment: Run nix develop. This enters a shell containing the OCaml compiler, dune, and other necessary tools. Once inside the shell, you can follow the OPAM build instructions.

    # Build the binary
    nix build
    
    # Enter development shell
    nix develop
  6. Check cooltt buffer status in Vim

    main

    While editing a .cooltt file, you can trigger checks to display the current buffer's status in a separate buffer using the following commands:

    • :Cooltt or <LocalLeader>l: Checks the entire current buffer.
    • <LocalLeader>p: Performs a partial check, ignoring lines below the current cursor position.

    From the resulting output buffer, you can press CTRL-] to jump directly to the location of the message in your source file.

    " Examples of commands in Normal mode
    :Cooltt
    :<LocalLeader>l
    :<LocalLeader>p
  7. Configure the cooltt binary path in Vim

    main

    If the cooltt binary is not available in your system's PATH, you must manually specify its location in your .vimrc using the g:cooltt_path variable.

    let g:cooltt_path = '/path/to/the-cooltt-binary'
  8. Type cooltt special characters using digraphs

    main

    cooltt uses specific Unicode characters. You can type these in Vim using the digraph feature (via Ctrl-k) or by using their ASCII equivalents.

    CharDigraphASCII
    𝕀C-k IIdim
    𝔽C-k FFcof
    ∂C-k dP
    ∧C-k AN/\
    ∨C-k OR\/
    ×C-k *X*
    →C-k ->->
  9. Configure cooltt CLI options

    main

    The cooltt CLI provides several flags to control input handling, output formatting, and server capabilities.

    Mode Selection

    • -m, --mode MODE: Set the interaction mode. Valid values are scripting (default) or interactive.
    • -i, --interactive: Shorthand for --mode interactive.

    Input and File Handling

    • FILE: The positional argument for the file to typecheck. Use - to read from standard input.
    • --as-file FILE: Pretend the input was located at FILE when searching for the project root. This is useful when reading from stdin to ensure relative imports/paths work correctly.

    Output and Debugging

    • -w, --width NUM: Set the maximum output width to NUM columns.
    • --debug: Enable debug mode to print internal operation information.

    Hole Server Options

    These options are only active if --server is enabled.

    • --server: Enable the cooltt hole server.
    • --server-hostname HOSTNAME: The hostname for the hole server (defaults to localhost).
    • --server-port PORT: The port for the hole server (defaults to 3001).
    cooltt --mode scripting --as-file ./project/term.ctt --width 80 term.ctt
    
    cooltt --server --server-port 8080