Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: minor tooling and doc improvements #1250

Merged
merged 5 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build status](https://badge.buildkite.com/7a9fd1213265a375385deec0a418bc4a6f26b17b7f4efe3cad.svg?branch=main)](https://buildkite.com/hackworthltd/primer)
[![Build status](https://badge.buildkite.com/210c4de83d47809721c2b4269b1d00393f3fa24c202abd4d45.svg?branch=main)](https://buildkite.com/hackworthltd/primer-ci)
[![Benchmarks](https://github.com/hackworthltd/primer/actions/workflows/benchmark-action.yaml/badge.svg?branch=main)](https://benchmarks.primer.dev)

# Primer
Expand Down Expand Up @@ -50,11 +50,14 @@ subject to change.
[DoS](https://en.wikipedia.org/wiki/Denial-of-service_attack) the
server on which it runs.

* The current implementation of the evaluator is very slow. Running
very large programs, or even small programs that generate many
reduction steps, is not practical at this time. We're well aware of
this limitation, and we plan to focus on evaluation performance once
version 1.0 of the language specification is complete.
* The current implementation of the step evaluator is very slow.
Running very large programs, or even small programs that generate
many reduction steps, is not practical at this time. Primer now also
features an interpreter which is up to a few orders of magnitude
faster than the step evaluator, but we lose the ability to step
through programs redex-at-a-time as we can with the step evaluator.
We plan to do future research to attempt to combine the two
approaches somehow.

* Even the most minor frontend requests result in the entire program
AST being sent over the network, rather than only what's changed.
Expand Down Expand Up @@ -83,9 +86,10 @@ subject to change.
* At the moment, Primer is a pure functional programming language,
with no effects system. This means, for example, it's not currently
possible to [draw animated cats](https://scratch.mit.edu) using
Primer. We plan to implement an effects system in version 2.0 of the
language specification, but that will work will not begin for some
time.
Primer. We're currently undecided on whether to add an effects
system to version 2.0 of the language, or to eschew language-level
effects entirely in favor of a different approach more suited to
novices.

* We've yet to do any rigorous testing of Primer with students, and
none at all in classrooms. Primer may turn out not be an effective
Expand Down
2 changes: 1 addition & 1 deletion docs/haskell-style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ import Foreword

## Cabal

* Start all new Cabal projects with `default-language: Haskell2010`.
* Start all new Cabal projects with `default-language: GHC2021`.
* Frequently-enabled GHC extensions should be considered for use in Cabal's `default-extensions` stanza.

## Tests
Expand Down
23 changes: 22 additions & 1 deletion flake.lock

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

95 changes: 53 additions & 42 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@

flake-parts.url = "github:hercules-ci/flake-parts";

treefmt-nix.url = "github:numtide/treefmt-nix";

# Let haskell.nix dictate the nixpkgs we use, as that will ensure
# better haskell.nix cache hits.
nixpkgs.follows = "haskell-nix/nixpkgs-unstable";
hacknix.inputs.nixpkgs.follows = "nixpkgs";
pre-commit-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";

ghc-wasm.url = "git+https://gitlab.haskell.org/ghc/ghc-wasm-meta";
};
Expand Down Expand Up @@ -73,6 +76,7 @@

imports = [
inputs.pre-commit-hooks-nix.flakeModule
inputs.treefmt-nix.flakeModule
];
systems = [ "x86_64-linux" "aarch64-darwin" ];

Expand Down Expand Up @@ -195,49 +199,16 @@
overlays = allOverlays;
};

pre-commit =
let
# Override the default nix-pre-commit-hooks tools with the version
# we're using.
haskellNixTools = pkgs.haskell-nix.tools ghcVersion {
hlint = "latest";
fourmolu = fourmoluVersion;
cabal-fmt = cabal-fmt-override;
};
in
{
check.enable = true;
settings = {
src = ./.;
hooks = {
hlint.enable = true;
fourmolu.enable = true;
cabal-fmt.enable = true;
nixpkgs-fmt.enable = true;
# Note: doesn't appear to pick up `bugreport.sh`.
# https://github.com/hackworthltd/primer/issues/1018
shellcheck.enable = true;
actionlint.enable = true;
};

# We need to force these due to
#
# https://github.com/cachix/pre-commit-hooks.nix/issues/204
tools = {
nixpkgs-fmt = pkgs.lib.mkForce pkgs.nixpkgs-fmt;
hlint = pkgs.lib.mkForce haskellNixTools.hlint;
fourmolu = pkgs.lib.mkForce haskellNixTools.fourmolu;
cabal-fmt = pkgs.lib.mkForce haskellNixTools.cabal-fmt;
};

excludes = [
"primer/test/outputs"
"primer-api/test/outputs"
"primer-service/test/outputs"
".buildkite/"
];
pre-commit = {
check.enable = true;
settings = {
src = ./.;
hooks = {
treefmt.enable = true;
actionlint.enable = true;
};
};
};

packages = {
inherit (pkgs) primer-service primer-client primer-openapi-spec;
Expand Down Expand Up @@ -319,8 +290,48 @@
})
// primerFlake.apps;

treefmt.config =
let
haskellExcludes = [
"primer/test/outputs"
"primer-api/test/outputs"
"primer-service/test/outputs"
];

haskellNixTools = pkgs.haskell-nix.tools ghcVersion {
hlint = "latest";
fourmolu = fourmoluVersion;
cabal-fmt = cabal-fmt-override;
};
in
{
projectRootFile = "flake.nix";

programs.hlint = {
enable = true;
package = haskellNixTools.hlint;
};
programs.cabal-fmt = {
enable = true;
package = haskellNixTools.cabal-fmt;
};
programs.fourmolu = {
enable = true;
package = haskellNixTools.fourmolu;
};
programs.nixpkgs-fmt.enable = true;
programs.shellcheck.enable = true;

settings.formatter.hlint.excludes = haskellExcludes;
settings.formatter.fourmolu.excludes = haskellExcludes;
};

devShells = {
default = primerFlake.devShell;
default = primerFlake.devShell // {
inputsFrom = [
config.treefmt.build.devShell
];
};
} // (pkgs.lib.optionalAttrs (system == "x86_64-linux")) {
# Unfortunately, this is only available on x86_64-linux.
wasm = pkgs.mkShell {
Expand Down
Loading