Skip to content

Commit

Permalink
Merge branch 'release-v0.7.0'
Browse files Browse the repository at this point in the history
* release-v0.7.0: (40 commits)
  Bump stackage nightly snapshot
  Bump version and update changelogs (and CITATION.cff)
  upd: nixpkgs
  upd: .cabal
  fix: shadowed names
  fix: move cli code into app
  fix: hpack config
  fix: nix expressions
  Fix lower bound on optparse-generic
  Exclude Language.Rzk.VSCode.Config from GHCJS build
  Replace `words` with a space in allowed characters
  Prevent adding a trailing space
  Add space after token only if not last in the line
  Improve rule for space inside parenthesis
  Remove 2 spaces when moving bin op to new line
  Consider '=' as a binary operator
  Move the more specific pattern above the catch-all
  Ensure formatDocument sends a response either way
  Add a handler for workspace/didChangeConfiguration
  Keep the lambda arrow as the last char on line
  ...
  • Loading branch information
fizruk committed Dec 8, 2023
2 parents f05581c + 004e213 commit 56f8621
Show file tree
Hide file tree
Showing 20 changed files with 607 additions and 99 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ghcjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ jobs:
clean: false
single-commit: true

- name: '🚀 Publish JS "binaries" (latest)'
if: ${{ startsWith(github.ref, 'refs/tags/') && startsWith(github.ref_name, 'v') && github.event_name == 'push' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
folder: rzk-playground-release
target-folder: latest/playground
clean: false
single-commit: true

- name: '🚀 Publish JS "binaries"'
if: ${{ github.ref_name == 'main' && github.event_name == 'push' }}
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
6 changes: 5 additions & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ authors:
- family-names: Kudasov
given-names: Nikolai
orcid: "https://orcid.org/0000-0001-6572-7292"
- family-names: Abounegm
given-names: Abdelrahman
- family-names: Danko
given-names: Danila
title: "Rzk: a proof assistant for synthetic $\\infty$-categories"
version: 0.6.7
version: 0.7.0
url: "https://github.com/rzk-lang/rzk"
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
# rzk
# Rzk proof assistant

[![MkDocs](https://shields.io/badge/MkDocs-documentation-informational)](https://rzk-lang.github.io/rzk/)
[![Haddock](https://shields.io/badge/Haddock-documentation-informational)](https://rzk-lang.github.io/rzk/haddock/index.html)
[![GHCJS build](https://github.com/rzk-lang/rzk/actions/workflows/ghcjs.yml/badge.svg?branch=main)](https://github.com/rzk-lang/rzk/actions/workflows/ghcjs.yml)
[![Release](https://img.shields.io/github/v/release/rzk-lang/rzk.svg)](https://github.com/rzk-lang/rzk/releases/latest)
[![`rzk` on Hackage](https://img.shields.io/hackage/v/rzk)](http://hackage.haskell.org/package/rzk)
[![`rzk` on Stackage Nightly](https://stackage.org/package/rzk/badge/nightly)](http://stackage.org/package/rzk)
[![`rzk` on Stackage LTS](https://stackage.org/package/rzk/badge/lts)](http://stackage.org/package/rzk)

[![Rzk documentation](https://shields.io/badge/MkDocs-Rzk%20documentation-informational)](https://rzk-lang.github.io/rzk/)
[![Rzk Playground](<https://shields.io/badge/Rzk%20Playground%20(latest)-online-success>)](https://rzk-lang.github.io/rzk/latest/playground/)
[![Rzk Zulip chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://rzk-lang.zulipchat.com)

[![Haddock](<https://shields.io/badge/Haddock%20(develop)-Code%20documentation-informational>)](https://rzk-lang.github.io/rzk/haddock/index.html)
[![Rzk Playground](<https://shields.io/badge/Rzk%20Playground%20(develop)-online-success>)](https://rzk-lang.github.io/rzk/develop/playground/)

An experimental proof assistant for synthetic ∞-categories.

<https://rzk-lang.github.io>

[![Early prototype demo.](images/split-demo-render.png)](https://rzk-lang.github.io/rzk/)

## About this project
Expand Down Expand Up @@ -80,6 +89,26 @@ Inside of such directory, you can run `rzk typecheck` on all files using wildcar
rzk typecheck *-*.md
```

### Formatting

Formatting can be done by calling `rzk format` and specifying the files to be formatted, e.g.:

```sh
rzk format file1.rzk file2.rzk
```

This prints the formatted version of the file to `stdout`.

To overwrite the file content, you must use the `--write` flag as such:

```sh
rzk format --write examples/*.rzk related/*.rzk.md
```

Note that if no files are specified, `rzk format` will format all files listed in `rzk.yaml`.

The CLI also supports the `--check` flag, which will exit with a non-zero exit code if any of the files are not formatted correctly. This is useful in CI pipelines to ensure that all files are formatted correctly.

## How to contribute to `rzk`

### Building the Documentation Locally
Expand Down
23 changes: 23 additions & 0 deletions docs/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to the
[Haskell Package Versioning Policy](https://pvp.haskell.org/).

## v0.7.0 — 2023-12-08

Major changes:

- Add an experimental `rzk format` command (by [Abdelrahman Abounegm](https://github.com/aabounegm), with feedback by [Fredrik Bakke](https://github.com/fredrik-bakke) (see [sHoTT#142](https://github.com/rzk-lang/sHoTT/pull/142)) and [Nikolai Kudasov](https://github.com/fizruk)):
- Automatically format files, partially automating the [Code Style of the sHoTT project](https://rzk-lang.github.io/sHoTT/STYLEGUIDE/)
- Notable features:
- Adds a space after the opening parenthesis to help with the [code tree structure](https://rzk-lang.github.io/sHoTT/STYLEGUIDE/#the-tree-structure-of-constructions)
- Puts the definition conclusion (type, starting with `:`) and construction (body, starting with `:=`) on new lines
- Adds a space after the `\` of a lambda term and around binary operators (like `,`)
- Moves binary operators to the beginning of the next line if they appear at the end of the previous one.
- Replaces [common ASCII sequences](https://rzk-lang.github.io/sHoTT/STYLEGUIDE/#use-of-unicode-characters) with their Unicode equivalent
- A CLI subcommand (`rzk format`) with `--check` and `--write` options
- Known limitations
- The 80 character line limit is currently not enforced due to the difficulty of determining where to add line breaks (for reference, check out [this post](https://journal.stuffwithstuff.com/2015/09/08/the-hardest-program-ive-ever-written/) by a Dart `fmt` engineer)
- Fixing indentation is not yet implemented due to the need for more semantics than the lexer provides to determine indentation level.
- There may be rare edge cases in which applying the formatter twice could result in additional edits that were not detected the first time.

Minor changes:

- Fix "latest" Rzk Playground link (see [#137](https://github.com/rzk-lang/rzk/pull/137));
- Add more badges to README (see [#136](https://github.com/rzk-lang/rzk/pull/136));

## v0.6.7 — 2023-10-07

- Fix build on some systems (fix `BNFC:bnfc` executable dependency, see [#125](https://github.com/rzk-lang/rzk/pull/125))
Expand Down
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/e1b4c97ed4ce160afd9ef1574b6a2ff168482f2a";
nixpkgs.url = "github:NixOS/nixpkgs/d1c3a8112f9d5d4840e0669727222e5fd9243451";
miso = {
url = "github:dmjio/miso/49edf0677253bbcdd473422b5dd5b4beffd83910";
flake = false;
Expand Down Expand Up @@ -47,6 +47,7 @@
packages = {
default = default.packages.default;
rzk = default.packages.${rzk};
rzk-ghcjs = ghcjs.packages.${rzk};
rzk-js = ghcjs.packages.${rzk-js};
} // scripts;

Expand Down
2 changes: 1 addition & 1 deletion hie.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cradle:
cabal:
stack:
48 changes: 27 additions & 21 deletions nix/ghcjs.nix
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
{ inputs, pkgs, scripts, rzk, rzk-js, rzk-src, rzk-js-src, ghcVersion, tools }:
let
inherit (pkgs.haskell.lib) overrideCabal;
misoNix = (import "${inputs.miso.outPath}/default.nix" { inherit (pkgs) system; });
misoNix = (import "${inputs.miso}/default.nix" { inherit (pkgs) system; });
pkgsMiso = misoNix.pkgs;

hpkgs =
# This isn't equivalent to `pkgsMiso.haskell.packages.ghcjs.override` ([link](https://nixos.wiki/wiki/Haskell#Overrides))
# but avoids multiple rebuilds
pkgsMiso.haskell.packages.ghcjs //
{
rzk = overrideCabal
(hpkgs.callCabal2nix rzk rzk-src { })
(x: {
isLibrary = true;
isExecutable = false;
pkgsMiso.haskell.packages.ghcjs.override {
overrides = final: prev: {
mkDerivation = args: prev.mkDerivation (args // {
doCheck = false;
doHaddock = false;
libraryToolDepends = [ pkgs.hpack pkgs.alex pkgs.happy ] ++ (x.libraryToolDepends or [ ]);
testToolDepends = [ pkgs.hpack pkgs.alex pkgs.happy ] ++ (x.testToolDepends or [ ]);
prePatch = "hpack --force";
});
rzk-js = overrideCabal
(hpkgs.callCabal2nix rzk-js rzk-js-src { inherit (hpkgs) rzk; })
(x: {
postInstall = (x.postInstall or "") + ''
cp $out/bin/${rzk-js} .
rm -r $out
cp ${rzk-js} $out
'';
hpack = pkgs.hpack;
rzk = (
(pkgsMiso.haskell.lib.overrideCabal
(prev.callCabal2nix rzk rzk-src { })
(x: {
isLibrary = true;
isExecutable = false;
buildTarget = "lib:rzk";
libraryToolDepends = [ pkgs.hpack pkgs.alex pkgs.happy ] ++ (x.libraryToolDepends or [ ]);
testToolDepends = [ pkgs.alex pkgs.happy ] ++ (x.testToolDepends or [ ]);
}))
).overrideAttrs (x: {
installPhase = builtins.replaceStrings [ "Setup copy" ] [ "Setup copy lib:rzk" ] x.installPhase;
});
rzk-js = overrideCabal
(final.callCabal2nix rzk-js rzk-js-src { })
(x: {
postInstall = (x.postInstall or "") + ''
cp $out/bin/${rzk-js} .
rm -r $out
cp ${rzk-js} $out
'';
});
};
};

hpkgsGHCJS_8_10_7 = pkgs.haskell.packages.ghcjs810.override ({
Expand Down
4 changes: 4 additions & 0 deletions rzk/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to the
[Haskell Package Versioning Policy](https://pvp.haskell.org/).

## v0.7.0 — 2023-12-08



## v0.6.7 — 2023-10-07

- Fix build on some systems (fix `BNFC:bnfc` executable dependency, see [#125](https://github.com/rzk-lang/rzk/pull/125))
Expand Down
89 changes: 84 additions & 5 deletions rzk/app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,14 +1,93 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE NamedFieldPuns #-}

module Main (main) where

#ifndef __GHCJS__
import Main.Utf8 (withUtf8)
#endif
import qualified Rzk.Main

import Control.Monad (forM, forM_, unless, when,
(>=>))
import Data.Version (showVersion)

#ifdef LSP
import Language.Rzk.VSCode.Lsp (runLsp)
#endif

import Options.Generic
import System.Exit (exitFailure, exitSuccess)

import Data.Functor ((<&>))
import Paths_rzk (version)
import Rzk.Format (formatFile, formatFileWrite,
isWellFormattedFile)
import Rzk.TypeCheck
import Rzk.Main

data FormatOptions = FormatOptions
{ check :: Bool
, write :: Bool
} deriving (Generic, Show, ParseRecord, Read, ParseField)

instance ParseFields FormatOptions where
parseFields _ _ _ _ = FormatOptions
<$> parseFields (Just "Check if the files are correctly formatted") (Just "check") (Just 'c') Nothing
<*> parseFields (Just "Write formatted file to disk") (Just "write") (Just 'w') Nothing

data Command
= Typecheck [FilePath]
| Lsp
| Format FormatOptions [FilePath]
| Version
deriving (Generic, Show, ParseRecord)

main :: IO ()
main =
main = do
#ifndef __GHCJS__
withUtf8
withUtf8 $
#endif
getRecord "rzk: an experimental proof assistant for synthetic ∞-categories" >>= \case
Typecheck paths -> do
modules <- parseRzkFilesOrStdin paths
case defaultTypeCheck (typecheckModulesWithLocation modules) of
Left err -> do
putStrLn "An error occurred when typechecking!"
putStrLn $ unlines
[ "Type Error:"
, ppTypeErrorInScopedContext' BottomUp err
]
exitFailure
Right _decls -> putStrLn "Everything is ok!"

Lsp ->
#ifdef LSP
void runLsp
#else
error "rzk lsp is not supported with this build"
#endif
Rzk.Main.main

Format (FormatOptions {check, write}) paths -> do
when (check && write) (error "Options --check and --write are mutually exclusive")
expandedPaths <- expandRzkPathsOrYaml paths
case expandedPaths of
[] -> error "No files found"
filePaths -> do
when (not check && not write) $ forM_ filePaths (formatFile >=> putStrLn)
when write $ forM_ filePaths formatFileWrite
when check $ do
results <- forM filePaths $ \path -> isWellFormattedFile path <&> (path,)
let notFormatted = map fst $ filter (not . snd) results
unless (null notFormatted) $ do
putStrLn "Some files are not well formatted:"
forM_ notFormatted $ \path -> putStrLn (" " <> path)
exitFailure
exitSuccess

Version -> putStrLn (showVersion version)

7 changes: 4 additions & 3 deletions rzk/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: rzk
version: 0.6.7
version: 0.7.0
github: "rzk-lang/rzk"
license: BSD3
author: "Nikolai Kudasov"
Expand Down Expand Up @@ -45,7 +45,6 @@ dependencies:
directory: ">= 1.2.7.0"
Glob: ">= 0.9.3"
mtl: ">= 2.2.2"
optparse-generic: ">= 1.3.0"
template-haskell: ">= 2.14.0.0"
text: ">= 1.2.3.1"
yaml: ">= 0.11.0.0"
Expand All @@ -72,11 +71,12 @@ library:
- Language.Rzk.Syntax.Skel
- condition: flag(lsp) && !impl(ghcjs)
exposed-modules:
- Language.Rzk.VSCode.Config
- Language.Rzk.VSCode.Env
- Language.Rzk.VSCode.Handlers
- Language.Rzk.VSCode.Logging
- Language.Rzk.VSCode.Lsp
- Language.Rzk.VSCode.Tokenize
- Language.Rzk.VSCode.Logging
dependencies:
aeson: ">= 1.4.2.0"
co-log-core: ">= 0.3.2.0"
Expand All @@ -102,6 +102,7 @@ executables:
- condition: "!impl(ghcjs)"
dependencies:
with-utf8: ">= 1.0.2.4"
optparse-generic: ">= 1.4.0"

tests:
rzk-test:
Expand Down
Loading

0 comments on commit 56f8621

Please sign in to comment.