Closes#2043
# Local usage notes
I suspect that HLS in VS Code spontaneously pollutes the `.hie` directory, because after a few successful invocations, `weeder` started complaining with:
```
incompatible hie file: /home/kostmo/github/swarm/.hie/Swarm/Web/Auth.hie
this version of weeder was compiled with GHC version 9064
the hie files in this project were generated with GHC version 9048
weeder must be built with the same GHC version as the project it is used on
```
## Fixing false positives
Previously, for each `library` and `executable`, the HIE directory was always the same:
```
ghc-options:
-hiedir=.hie
```
However, most of the executables have at least one module path that is the same relative to their `hs-source-dirs` base: namely, `Main.hs`. This resulted in all but one of the `Main.hie` files being overwritten in the end.
To avoid this, I have specified a different `-hiedir` for each `library`/`executable`/`test` that parallels its `hs-source-dirs` base. This way, so long as `hs-source-dirs` are unique across these targets, all of the `*.hs` files across the entire project will have unique `*.hie` paths.
## Whitelisting exceptions
There are some known limitations with `weeder` regarding support for Template Haskell and type families. Exceptions are specified in the `roots` list in `weeder.toml`.
After removing a handful of dead functions myself, there are approx. 30 "true positive" weeds that I have listed explicitly in `weeder.toml`. Maintenance of this list of exceptions should eventually be easier with https://github.com/ocharles/weeder/issues/146.
# Integration with CI
I found a ready-made GitHub Action for weeder: https://github.com/freckle/weeder-action
I hacked support directly into the generated `.github/workflows/haskell-ci.yml` file.
Ideally, the generator would have an option for a `weeder` step. Indeed, there is an open issue for supporting `weeder` in `haskell-ci`: https://github.com/haskell-CI/haskell-ci/issues/132
A separate but related functionality that would be nice in `haskell-ci` is to specify **one** of the GHC versions in the matrix to do additional validations/builds that would be redundant if performed on the other matrix entries. I suppose `weeder` is inexpensive enough to redo four times, but the `weeder` binary is not available for download for all GHC versions (e.g. ghc `9.8.2`). Something like `haddock` we probably only need to build once.
I have hacked this in to the generated file for `weeder` with a simple [`if` condition](https://github.com/swarm-game/swarm/pull/2044/files#diff-73f8a010e9b95aa9fe944c316576b12c2ec961272d428e38721112ecb1c1a98bR227).
The `create_release` job worked fine. The `build_artifact` job, however, after downloading the `release_url` artifact, seemed to be looking for it in the wrong place --- it tried to access `release_url/release_url.txt`, but the corrsponding zip file contains only the file `release_url.txt` with no folder.
This PR fixes the job to look for the `release_url.txt` file in the correct (I hope) place.
* move Mergify, Restyled, Haskell-CI and Pull Request template to `.github`
* regenerate Haskell-CI file with the new path and new Haskell CI version
* move CSpell from VSCode [Code Spell Checker](https://open-vsx.org/extension/streetsidesoftware/code-spell-checker) extension to `.vscode`
This is a complementary top-level cleanup to #2015.
* Update VSCode plugin NPM package
* Update VSCode syntax
* Rewrite the `definition` rule to make it simpler and work with multiline types
* Use shared `#types` group with added support for `rec`
* Refactor groups to use ordered include `patterns` and unordered `repository` of named subgroups
* Add escape sequences to strings
* Fix a typo in a regular expression that broke syntax highlighting
* Generate the syntax JSON file from YAML
---
* Closes#1887
Make sure Swarm builds with the most recent versions of dependencies. The only one that is still lagging is `filepath`, but `servant` doesn't support `filepath-1.5` so Swarm can't either.
The only real update needed was due to some breaking changes in `aeson-2.2`, but the necessary changes were very minor. Also fixed a few places where GHC 9.8 is generating additional warnings.
Also update our CI: `haskell-ci` recently dropped support for `hlint`, in favor of projects defining their own standalone `hlint` workflows.
Closes#1661; towards #154.
`unification-fd` is very powerful, and extremely fast, but it was written a long time ago and its age shows. It was not possible to incorporate it into our effects system in a nice way, necessitating the use of concrete monad transformers in the typechecking code. In addition it is impossible to customize, and we have been contemplating new type system features such as #153 and #154 that turn out to require hooking into the way the unification algorithm works (see https://github.com/swarm-game/swarm/issues/154#issuecomment-1822877487 for more details).
This PR thus removes the dependency on `unification-fd` and implements our own version of unification. It is not quite as fast as `unification-fd` but I consider the slowdown acceptable in order to gain e.g. recursive types. And of course there is also room to optimize it.
The custom `UTerm` from `unification-fd` is replaced with the standard `Free` (free monad) construction from the `free` package, and the custom `Fix` from `unification-fd` is replaced with the one from `data-fix`.
We also get rid of the `unifyCheck` function, which used to be a quick short-circuiting way to check whether two types definitely did not unify or might unify, allowing us to give better error messages more quickly. Now, the `=:=` unification operator itself just does this.
Update to use the `lsp-2.4` API. Closes#1350.
Initially I hoped that any `lsp-2.x` would work. However, the `SeverDefinition` record changed in `2.2` so I initially set that as a lower bound. But then it turns out that `2.4` changed which module it is importing `Rope` from; since we work with ropes in the `Hover` module it matters since we have to import the matching module. Updating to the new `Rope` type also required some changes as the API provided by the new `Rope.Mixed` module is a bit different than the old module, so we would not even be able to easily put in CPP to conditionally depend on the right rope module depending on the `lsp` version. Finally, this means dropping support for GHC 9.0 since `lsp-2.4` does not support it.
Along the way I also fixed a minor issue related to showing type information returned by the LSP server, so that it uses `prettyTypeLine` to display the type on a single line (in my editor, when the type does not use a single line it gets cut off). For comparison see also #1610.
This refactoring was a big pain because a lot of things (names of types and constructors, locations of exports, etc...) changed from 1.x to 2.x, but there was not much in the way of documenting what had changed. =( I am pretty sure that all functionality has been preserved but I would appreciate independent confirmation.
This is also a prerequisite for updating other dependencies such as the `base` version (I will open a follow-up PR soon) since the old `lsp-1.x` versions do not allow many newer versions of various dependencies.
* move the VSCode extension under "swarm-game" organisation
* add Open VSX Registry to "Deploy Extension" GitHub Action
* bump version, so it gets pushed once tagged
* closes#1453
Closes#1428
Since the authoritative validation of scenario files is actually performed by virtue of `swarm` parsing them, this CI job actually exists to ensure the JSON Schema descriptions are accurate. This is important for two purposes:
* Documentation is generated from the JSON Schema files (#1436)
* JSON Schema has integration with VS Code and other IDEs
# Testing
Verified that the schema checker action does indeed work by intentionally pushing an invalid scenario file in f789f81.
Support GHC 9.6 / `base-4.18`, `mtl-2.3`, `megaparsec-9.4`, `servant-0.20`, `servant-docs-0.13`, `servant-server-0.20`, `template-haskell-2.20`, `optparse-applicative-0.18`, fix a bunch of new warnings, and update CI to test on GHC 9.6.
---------
Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
Co-authored-by: Restyled.io <commits@restyled.io>
Previously the action did not run because of an error:
```
The workflow is not valid. .github/workflows/check_todos.yml (Line: 14, Col: 3):
The identifier 'Enforce issue references' is invalid. IDs may only contain alphanumeric characters, '_', and '-'.
IDs must start with a letter or '_' and and must be less than 100 characters.
```
- fixes#1101
- replace `XXX` with `TODO: #<issue number>`
TODO has simply better editor support. The GitHub plugin will suggest creating an issue for TODO that does not have the issue number after it and some editors may even ask for confirmation when committing code with TODO.
- bump extension version to 0.0.6
- fix highlighting
- do not let an "empty decimal" (`[0-9]*`) match every time. 😉
- add snapshot test
- add VSCode GitHub Action to build and test
- add VSCode GitHub Action to release the extension
- it is triggered when pushing a tag `swarm-language-vscode-*`
- closes#609
- query GitHub Releases for a new version
- add `swarm version` command
- show the version notification in the main menu
- add a new app-wide logging queue
- show the app-wide logs in the main menu as Messages
- catch and show the web API failure in the Messages
- closes#66
- closes#627
The action presently runs twice because both `on` conditions matche
every contributions. With this change, the push action only triggers
for the final push to the main branch, and the pull_requeste action
only triggers for PR made for the main branch.
That also means restyled PR should not trigger CI as they are made
for non main branches.
* Fix doctests
* Regenerate haskell-ci with config
- use latest haskell-ci
- configure haskell-ci to use doctest
* Update tested with compiler
- update cabal tested-with field
- update .mergify.yaml to new compiler
- restore note about mergify in haskell-ci