Skip to content

Commit 56f8621

Browse files
committed
Merge branch 'release-v0.7.0'
* 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 ...
2 parents f05581c + 004e213 commit 56f8621

File tree

20 files changed

+607
-99
lines changed

20 files changed

+607
-99
lines changed

.github/workflows/ghcjs.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ jobs:
9292
clean: false
9393
single-commit: true
9494

95+
- name: '🚀 Publish JS "binaries" (latest)'
96+
if: ${{ startsWith(github.ref, 'refs/tags/') && startsWith(github.ref_name, 'v') && github.event_name == 'push' }}
97+
uses: JamesIves/github-pages-deploy-action@v4
98+
with:
99+
token: ${{ secrets.GITHUB_TOKEN }}
100+
folder: rzk-playground-release
101+
target-folder: latest/playground
102+
clean: false
103+
single-commit: true
104+
95105
- name: '🚀 Publish JS "binaries"'
96106
if: ${{ github.ref_name == 'main' && github.event_name == 'push' }}
97107
uses: JamesIves/github-pages-deploy-action@v4

CITATION.cff

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ authors:
33
- family-names: Kudasov
44
given-names: Nikolai
55
orcid: "https://orcid.org/0000-0001-6572-7292"
6+
- family-names: Abounegm
7+
given-names: Abdelrahman
8+
- family-names: Danko
9+
given-names: Danila
610
title: "Rzk: a proof assistant for synthetic $\\infty$-categories"
7-
version: 0.6.7
11+
version: 0.7.0
812
url: "https://github.com/rzk-lang/rzk"

README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
# rzk
1+
# Rzk proof assistant
22

3-
[![MkDocs](https://shields.io/badge/MkDocs-documentation-informational)](https://rzk-lang.github.io/rzk/)
4-
[![Haddock](https://shields.io/badge/Haddock-documentation-informational)](https://rzk-lang.github.io/rzk/haddock/index.html)
5-
[![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)
3+
[![Release](https://img.shields.io/github/v/release/rzk-lang/rzk.svg)](https://github.com/rzk-lang/rzk/releases/latest)
4+
[![`rzk` on Hackage](https://img.shields.io/hackage/v/rzk)](http://hackage.haskell.org/package/rzk)
5+
[![`rzk` on Stackage Nightly](https://stackage.org/package/rzk/badge/nightly)](http://stackage.org/package/rzk)
6+
[![`rzk` on Stackage LTS](https://stackage.org/package/rzk/badge/lts)](http://stackage.org/package/rzk)
7+
8+
[![Rzk documentation](https://shields.io/badge/MkDocs-Rzk%20documentation-informational)](https://rzk-lang.github.io/rzk/)
9+
[![Rzk Playground](<https://shields.io/badge/Rzk%20Playground%20(latest)-online-success>)](https://rzk-lang.github.io/rzk/latest/playground/)
610
[![Rzk Zulip chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://rzk-lang.zulipchat.com)
711

12+
[![Haddock](<https://shields.io/badge/Haddock%20(develop)-Code%20documentation-informational>)](https://rzk-lang.github.io/rzk/haddock/index.html)
13+
[![Rzk Playground](<https://shields.io/badge/Rzk%20Playground%20(develop)-online-success>)](https://rzk-lang.github.io/rzk/develop/playground/)
14+
815
An experimental proof assistant for synthetic ∞-categories.
916

17+
<https://rzk-lang.github.io>
18+
1019
[![Early prototype demo.](images/split-demo-render.png)](https://rzk-lang.github.io/rzk/)
1120

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

92+
### Formatting
93+
94+
Formatting can be done by calling `rzk format` and specifying the files to be formatted, e.g.:
95+
96+
```sh
97+
rzk format file1.rzk file2.rzk
98+
```
99+
100+
This prints the formatted version of the file to `stdout`.
101+
102+
To overwrite the file content, you must use the `--write` flag as such:
103+
104+
```sh
105+
rzk format --write examples/*.rzk related/*.rzk.md
106+
```
107+
108+
Note that if no files are specified, `rzk format` will format all files listed in `rzk.yaml`.
109+
110+
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.
111+
83112
## How to contribute to `rzk`
84113

85114
### Building the Documentation Locally

docs/docs/CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to the
77
[Haskell Package Versioning Policy](https://pvp.haskell.org/).
88

9+
## v0.7.0 — 2023-12-08
10+
11+
Major changes:
12+
13+
- 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)):
14+
- Automatically format files, partially automating the [Code Style of the sHoTT project](https://rzk-lang.github.io/sHoTT/STYLEGUIDE/)
15+
- Notable features:
16+
- 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)
17+
- Puts the definition conclusion (type, starting with `:`) and construction (body, starting with `:=`) on new lines
18+
- Adds a space after the `\` of a lambda term and around binary operators (like `,`)
19+
- Moves binary operators to the beginning of the next line if they appear at the end of the previous one.
20+
- Replaces [common ASCII sequences](https://rzk-lang.github.io/sHoTT/STYLEGUIDE/#use-of-unicode-characters) with their Unicode equivalent
21+
- A CLI subcommand (`rzk format`) with `--check` and `--write` options
22+
- Known limitations
23+
- 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)
24+
- Fixing indentation is not yet implemented due to the need for more semantics than the lexer provides to determine indentation level.
25+
- There may be rare edge cases in which applying the formatter twice could result in additional edits that were not detected the first time.
26+
27+
Minor changes:
28+
29+
- Fix "latest" Rzk Playground link (see [#137](https://github.com/rzk-lang/rzk/pull/137));
30+
- Add more badges to README (see [#136](https://github.com/rzk-lang/rzk/pull/136));
31+
932
## v0.6.7 — 2023-10-07
1033

1134
- Fix build on some systems (fix `BNFC:bnfc` executable dependency, see [#125](https://github.com/rzk-lang/rzk/pull/125))

flake.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
inputs = {
33
flake-utils.url = "github:numtide/flake-utils";
4-
nixpkgs.url = "github:NixOS/nixpkgs/e1b4c97ed4ce160afd9ef1574b6a2ff168482f2a";
4+
nixpkgs.url = "github:NixOS/nixpkgs/d1c3a8112f9d5d4840e0669727222e5fd9243451";
55
miso = {
66
url = "github:dmjio/miso/49edf0677253bbcdd473422b5dd5b4beffd83910";
77
flake = false;
@@ -47,6 +47,7 @@
4747
packages = {
4848
default = default.packages.default;
4949
rzk = default.packages.${rzk};
50+
rzk-ghcjs = ghcjs.packages.${rzk};
5051
rzk-js = ghcjs.packages.${rzk-js};
5152
} // scripts;
5253

hie.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
cradle:
2-
cabal:
2+
stack:

nix/ghcjs.nix

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,40 @@
11
{ inputs, pkgs, scripts, rzk, rzk-js, rzk-src, rzk-js-src, ghcVersion, tools }:
22
let
33
inherit (pkgs.haskell.lib) overrideCabal;
4-
misoNix = (import "${inputs.miso.outPath}/default.nix" { inherit (pkgs) system; });
4+
misoNix = (import "${inputs.miso}/default.nix" { inherit (pkgs) system; });
55
pkgsMiso = misoNix.pkgs;
66

77
hpkgs =
8-
# This isn't equivalent to `pkgsMiso.haskell.packages.ghcjs.override` ([link](https://nixos.wiki/wiki/Haskell#Overrides))
9-
# but avoids multiple rebuilds
10-
pkgsMiso.haskell.packages.ghcjs //
11-
{
12-
rzk = overrideCabal
13-
(hpkgs.callCabal2nix rzk rzk-src { })
14-
(x: {
15-
isLibrary = true;
16-
isExecutable = false;
8+
pkgsMiso.haskell.packages.ghcjs.override {
9+
overrides = final: prev: {
10+
mkDerivation = args: prev.mkDerivation (args // {
1711
doCheck = false;
1812
doHaddock = false;
19-
libraryToolDepends = [ pkgs.hpack pkgs.alex pkgs.happy ] ++ (x.libraryToolDepends or [ ]);
20-
testToolDepends = [ pkgs.hpack pkgs.alex pkgs.happy ] ++ (x.testToolDepends or [ ]);
21-
prePatch = "hpack --force";
2213
});
23-
rzk-js = overrideCabal
24-
(hpkgs.callCabal2nix rzk-js rzk-js-src { inherit (hpkgs) rzk; })
25-
(x: {
26-
postInstall = (x.postInstall or "") + ''
27-
cp $out/bin/${rzk-js} .
28-
rm -r $out
29-
cp ${rzk-js} $out
30-
'';
14+
hpack = pkgs.hpack;
15+
rzk = (
16+
(pkgsMiso.haskell.lib.overrideCabal
17+
(prev.callCabal2nix rzk rzk-src { })
18+
(x: {
19+
isLibrary = true;
20+
isExecutable = false;
21+
buildTarget = "lib:rzk";
22+
libraryToolDepends = [ pkgs.hpack pkgs.alex pkgs.happy ] ++ (x.libraryToolDepends or [ ]);
23+
testToolDepends = [ pkgs.alex pkgs.happy ] ++ (x.testToolDepends or [ ]);
24+
}))
25+
).overrideAttrs (x: {
26+
installPhase = builtins.replaceStrings [ "Setup copy" ] [ "Setup copy lib:rzk" ] x.installPhase;
3127
});
28+
rzk-js = overrideCabal
29+
(final.callCabal2nix rzk-js rzk-js-src { })
30+
(x: {
31+
postInstall = (x.postInstall or "") + ''
32+
cp $out/bin/${rzk-js} .
33+
rm -r $out
34+
cp ${rzk-js} $out
35+
'';
36+
});
37+
};
3238
};
3339

3440
hpkgsGHCJS_8_10_7 = pkgs.haskell.packages.ghcjs810.override ({

rzk/ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to the
77
[Haskell Package Versioning Policy](https://pvp.haskell.org/).
88

9+
## v0.7.0 — 2023-12-08
10+
11+
12+
913
## v0.6.7 — 2023-10-07
1014

1115
- Fix build on some systems (fix `BNFC:bnfc` executable dependency, see [#125](https://github.com/rzk-lang/rzk/pull/125))

rzk/app/Main.hs

Lines changed: 84 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,93 @@
1-
{-# LANGUAGE CPP #-}
1+
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE DeriveAnyClass #-}
3+
{-# LANGUAGE DeriveGeneric #-}
4+
{-# LANGUAGE LambdaCase #-}
5+
{-# LANGUAGE OverloadedStrings #-}
6+
{-# LANGUAGE TupleSections #-}
7+
{-# LANGUAGE NamedFieldPuns #-}
8+
29
module Main (main) where
310

411
#ifndef __GHCJS__
512
import Main.Utf8 (withUtf8)
613
#endif
7-
import qualified Rzk.Main
14+
15+
import Control.Monad (forM, forM_, unless, when,
16+
(>=>))
17+
import Data.Version (showVersion)
18+
19+
#ifdef LSP
20+
import Language.Rzk.VSCode.Lsp (runLsp)
21+
#endif
22+
23+
import Options.Generic
24+
import System.Exit (exitFailure, exitSuccess)
25+
26+
import Data.Functor ((<&>))
27+
import Paths_rzk (version)
28+
import Rzk.Format (formatFile, formatFileWrite,
29+
isWellFormattedFile)
30+
import Rzk.TypeCheck
31+
import Rzk.Main
32+
33+
data FormatOptions = FormatOptions
34+
{ check :: Bool
35+
, write :: Bool
36+
} deriving (Generic, Show, ParseRecord, Read, ParseField)
37+
38+
instance ParseFields FormatOptions where
39+
parseFields _ _ _ _ = FormatOptions
40+
<$> parseFields (Just "Check if the files are correctly formatted") (Just "check") (Just 'c') Nothing
41+
<*> parseFields (Just "Write formatted file to disk") (Just "write") (Just 'w') Nothing
42+
43+
data Command
44+
= Typecheck [FilePath]
45+
| Lsp
46+
| Format FormatOptions [FilePath]
47+
| Version
48+
deriving (Generic, Show, ParseRecord)
849

950
main :: IO ()
10-
main =
51+
main = do
1152
#ifndef __GHCJS__
12-
withUtf8
53+
withUtf8 $
54+
#endif
55+
getRecord "rzk: an experimental proof assistant for synthetic ∞-categories" >>= \case
56+
Typecheck paths -> do
57+
modules <- parseRzkFilesOrStdin paths
58+
case defaultTypeCheck (typecheckModulesWithLocation modules) of
59+
Left err -> do
60+
putStrLn "An error occurred when typechecking!"
61+
putStrLn $ unlines
62+
[ "Type Error:"
63+
, ppTypeErrorInScopedContext' BottomUp err
64+
]
65+
exitFailure
66+
Right _decls -> putStrLn "Everything is ok!"
67+
68+
Lsp ->
69+
#ifdef LSP
70+
void runLsp
71+
#else
72+
error "rzk lsp is not supported with this build"
1373
#endif
14-
Rzk.Main.main
74+
75+
Format (FormatOptions {check, write}) paths -> do
76+
when (check && write) (error "Options --check and --write are mutually exclusive")
77+
expandedPaths <- expandRzkPathsOrYaml paths
78+
case expandedPaths of
79+
[] -> error "No files found"
80+
filePaths -> do
81+
when (not check && not write) $ forM_ filePaths (formatFile >=> putStrLn)
82+
when write $ forM_ filePaths formatFileWrite
83+
when check $ do
84+
results <- forM filePaths $ \path -> isWellFormattedFile path <&> (path,)
85+
let notFormatted = map fst $ filter (not . snd) results
86+
unless (null notFormatted) $ do
87+
putStrLn "Some files are not well formatted:"
88+
forM_ notFormatted $ \path -> putStrLn (" " <> path)
89+
exitFailure
90+
exitSuccess
91+
92+
Version -> putStrLn (showVersion version)
93+

0 commit comments

Comments
 (0)