diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0e7c4a36..62911784 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,12 +35,6 @@ To do so: All PRs will be considered, but going through the above process significantly improves your chances of a merge! -## Local development commands - -- build: `cabal build -f dev` -- run tests: `cabal test -f dev` -- format files: `ormolu --mode inplace $(git ls-files '*.hs')` - ## Back-up / Historic Archives There's also a [Zulip](https://gren.zulipchat.com) with older diff --git a/README.md b/README.md index add15cf3..861cfc14 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,23 @@ There are easier ways to install the compiler than compiling the source, you mig ## Build from source -The Gren compiler is written in Haskell, so to build from source you need to have GHC 9.4 (Haskell compiler) and Cabal 3.8 (haskell build tool) installed on your system. +This project uses [devbox](https://www.jetify.com/devbox) for managing dependencies required to build the project. If you don't want to use devbox, +you can find a list of the requried dependencies and the commands for building the compiler in `devbox.json`. -You can install these using [ghcup](https://www.haskell.org/ghcup/). By default, ghcup will install an older version of Haskell and Cabal, so you can install and set the required versions using `ghcup tui`. +Since Gren 0.4 the compiler is implemented in two parts. The Gren-part of the compiler lives in `src`, and once built it acts +as a frontend to the Haskell-part of the compiler. -Compiling and installing the project should just be a matter of `cabal install`, after which you should be able to run the `gren` command from your command line. +The end goal is for the entire compiler to be written in Gren. -Read the `CONTRIBUTING.md` file for some helpful commands for working on the compiler itself. +To build the compiler: + +1. Use `devbox run prepare-deps` to setup the required dependencies. The first time you run this it might take a while. +2. Build the compiler with `devbox run build`. This will create a `cli.js` file and a `gren` executable in the project root directory. + +You can now execute the Gren-part of the compiler with `node ./cli.js` or just `./cli.js`. This either requires `node` to be installed, +or that you've entered the development shell by using `devbox shell`. The Gren-part of the compiler will by default download a pre-built +binary of the Haskell-part from Github. If you want to run the compiler with the Haskell-part you've just built, set the path +to the Haskell-binary in a `GREN_BIN` environment variable, like: `GREN_BIN=$PWD/gren node ./cli.js`. + +You might also want to study the scripts defined in `devbox.json`. You can execute one of these scripts by running +`devbox run `. diff --git a/ROADMAP.md b/ROADMAP.md index 904c67b4..f70877ed 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -8,16 +8,5 @@ Also, keep in mind that this only focuses on the big picture. Major features lik ## Releases -- December 2023 - Parametric modules, or OCaml functors, to enable defining things like equality, comparisons etc. for your own types and use them in data structures like Dict. This release also removes the "magic" type classes currently in the language, like `number` and `comparable`. - -- June 2024 - Stabelization period. Mostly bugfixes and code gen improvements. While we prepare for the next big thing. - -- December 2024 - Re-evaluating how concurrency works in the language. More specifically, we'll re-evaluate how `Task`, `Cmd`, `Process` and effect modules work. - -- June 2025 - Re-evaluate records and custom types. - -- December 2025 - Re-evaluate interop: ports and kernel code. - -- June 2026 - Compile to Web Assembly instead of JS. This will give us proper integers, big integers, hopefully smaller asset size and possibly enable future optimizations in codegen. - -- December 2026 - The language is considered complete. Both the compiler and core packages will commit to maintaining backwards compatability from here on out. +- June 2025 - Rewrite dependency management in Gren +- December 2025 - Rewrite parser in Gren. Parametric modules. Operators as syntax sugar. diff --git a/devbox.json b/devbox.json index fb17eea6..d4fb367e 100644 --- a/devbox.json +++ b/devbox.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.13.4/.schema/devbox.schema.json", + "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.13.5/.schema/devbox.schema.json", "packages": [ "nodejs@20", "ghc@9.4.8", @@ -11,6 +11,20 @@ "echo 'Welcome to devbox!' > /dev/null" ], "scripts": { + "prepare-deps": [ + "cabal update", + "npm ci" + ], + "build": [ + "npm run prepublishOnly", + "./build_dev_bin.sh" + ], + "test": [ + "cabal test" + ], + "compiler": [ + "GREN_BIN=$PWD/gren node cli.js" + ], "format": [ "ormolu --mode inplace $(git ls-files '*.hs')", "npm run prettier" @@ -18,13 +32,6 @@ "format:check": [ "ormolu --check-idempotence --mode check $(git ls-files '*.hs')", "npm run prettier:check" - ], - "build": [ - "./build_dev_bin.sh", - "npm run prepublishOnly" - ], - "test": [ - "cabal test" ] } } diff --git a/devbox.lock b/devbox.lock index 1c401929..45f86e66 100644 --- a/devbox.lock +++ b/devbox.lock @@ -115,9 +115,9 @@ } }, "nodejs@20": { - "last_modified": "2024-09-10T15:01:03Z", + "last_modified": "2024-10-13T23:44:06Z", "plugin_version": "0.0.2", - "resolved": "github:NixOS/nixpkgs/5ed627539ac84809c78b2dd6d26a5cebeb5ae269#nodejs_20", + "resolved": "github:NixOS/nixpkgs/d4f247e89f6e10120f911e2e2d2254a050d0f732#nodejs_20", "source": "devbox-search", "version": "20.17.0", "systems": { @@ -125,63 +125,63 @@ "outputs": [ { "name": "out", - "path": "/nix/store/hxl1k8qgmrm1vfq5f419iv4wybz9szqq-nodejs-20.17.0", + "path": "/nix/store/fkapwdcjn9fm1n071jv7a75cw66x4wq7-nodejs-20.17.0", "default": true }, { "name": "libv8", - "path": "/nix/store/baf3p9zf8dn2arp6wjkdi3v0g2xgfd6y-nodejs-20.17.0-libv8" + "path": "/nix/store/17gly8aw2qa535bw1014xbc264v496g1-nodejs-20.17.0-libv8" } ], - "store_path": "/nix/store/hxl1k8qgmrm1vfq5f419iv4wybz9szqq-nodejs-20.17.0" + "store_path": "/nix/store/fkapwdcjn9fm1n071jv7a75cw66x4wq7-nodejs-20.17.0" }, "aarch64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/vc64zpxndmp3xh9699yb2vpbl81pxbk0-nodejs-20.17.0", + "path": "/nix/store/icf1zdxjpik986hqwa9vj33zk9ir5r7h-nodejs-20.17.0", "default": true }, { "name": "libv8", - "path": "/nix/store/0c57mzp5bqf0pp4a0pdj8wynphsgi92c-nodejs-20.17.0-libv8" + "path": "/nix/store/yqira4250smxxpnxg3jc7r1csrsdz9yx-nodejs-20.17.0-libv8" } ], - "store_path": "/nix/store/vc64zpxndmp3xh9699yb2vpbl81pxbk0-nodejs-20.17.0" + "store_path": "/nix/store/icf1zdxjpik986hqwa9vj33zk9ir5r7h-nodejs-20.17.0" }, "x86_64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/lgyrki1i0205nwh51c1h22bhl95x0nyd-nodejs-20.17.0", + "path": "/nix/store/pfg4yz6c5kvk8wp29kvp56dl0yjahwgn-nodejs-20.17.0", "default": true }, { "name": "libv8", - "path": "/nix/store/n4xvswmgb3ql2440bkl8xk4i3b11w46x-nodejs-20.17.0-libv8" + "path": "/nix/store/qm9202yha093jx33jkgxv2ra6yzgw6d2-nodejs-20.17.0-libv8" } ], - "store_path": "/nix/store/lgyrki1i0205nwh51c1h22bhl95x0nyd-nodejs-20.17.0" + "store_path": "/nix/store/pfg4yz6c5kvk8wp29kvp56dl0yjahwgn-nodejs-20.17.0" }, "x86_64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/w78sh036dyn14f29w8za9ni9syrmwm3q-nodejs-20.17.0", + "path": "/nix/store/dcdc33kdjdhjnzg6rkmd0cx4kpwl8cac-nodejs-20.17.0", "default": true }, { "name": "libv8", - "path": "/nix/store/bsqha32xvv1j20bwkhr2wsnclk4qsi3a-nodejs-20.17.0-libv8" + "path": "/nix/store/bv92rqliq5vnpwa2pwsdiphz48j87l47-nodejs-20.17.0-libv8" } ], - "store_path": "/nix/store/w78sh036dyn14f29w8za9ni9syrmwm3q-nodejs-20.17.0" + "store_path": "/nix/store/dcdc33kdjdhjnzg6rkmd0cx4kpwl8cac-nodejs-20.17.0" } } }, "ormolu@0.7": { - "last_modified": "2024-10-06T02:39:15Z", - "resolved": "github:NixOS/nixpkgs/7d49afd36b5590f023ec56809c02e05d8164fbc4#ormolu", + "last_modified": "2024-10-13T23:44:06Z", + "resolved": "github:NixOS/nixpkgs/d4f247e89f6e10120f911e2e2d2254a050d0f732#ormolu", "source": "devbox-search", "version": "0.7.2.0", "systems": { @@ -189,57 +189,57 @@ "outputs": [ { "name": "bin", - "path": "/nix/store/m628xcmly4v168zrijnlvqd2vm64cs78-ormolu-0.7.2.0-bin", + "path": "/nix/store/6ldik7pz7ivf2krr706rhb40zi1921xg-ormolu-0.7.2.0-bin", "default": true }, { "name": "out", - "path": "/nix/store/lgjigpsgmqi54pmpmrzbpzxp8swh3dmc-ormolu-0.7.2.0" + "path": "/nix/store/gan5i2l229qp3mwyhsxvzsynjj3jl7vh-ormolu-0.7.2.0" } ], - "store_path": "/nix/store/m628xcmly4v168zrijnlvqd2vm64cs78-ormolu-0.7.2.0-bin" + "store_path": "/nix/store/6ldik7pz7ivf2krr706rhb40zi1921xg-ormolu-0.7.2.0-bin" }, "aarch64-linux": { "outputs": [ { "name": "bin", - "path": "/nix/store/clvpg96xy2wg0hn6z1vylfkbha6rvsqf-ormolu-0.7.2.0-bin", + "path": "/nix/store/37vh0cnlj4lk58m3c0nna5azf8l9lyxw-ormolu-0.7.2.0-bin", "default": true }, { "name": "out", - "path": "/nix/store/3jjl8awy6g0l3158szvlil6siy9ijp35-ormolu-0.7.2.0" + "path": "/nix/store/nm6sr2zmk1j8hrkrrzs6kr2igsa6vqsi-ormolu-0.7.2.0" } ], - "store_path": "/nix/store/clvpg96xy2wg0hn6z1vylfkbha6rvsqf-ormolu-0.7.2.0-bin" + "store_path": "/nix/store/37vh0cnlj4lk58m3c0nna5azf8l9lyxw-ormolu-0.7.2.0-bin" }, "x86_64-darwin": { "outputs": [ { "name": "bin", - "path": "/nix/store/xjnq2hb0wza1msy3pq1avqf5h8gj48hz-ormolu-0.7.2.0-bin", + "path": "/nix/store/6zvrcw031fl96zj1579gakszxhng92vc-ormolu-0.7.2.0-bin", "default": true }, { "name": "out", - "path": "/nix/store/vp7q2lyar4wvkcyf89a7b8f6grjmmciz-ormolu-0.7.2.0" + "path": "/nix/store/wjn200gcgbxlh5l9pnn9g2pqz3rl2mmd-ormolu-0.7.2.0" } ], - "store_path": "/nix/store/xjnq2hb0wza1msy3pq1avqf5h8gj48hz-ormolu-0.7.2.0-bin" + "store_path": "/nix/store/6zvrcw031fl96zj1579gakszxhng92vc-ormolu-0.7.2.0-bin" }, "x86_64-linux": { "outputs": [ { "name": "bin", - "path": "/nix/store/vlp9vbp2yibfcwpax8xp3yqfvagwm8sb-ormolu-0.7.2.0-bin", + "path": "/nix/store/31wjfy7cwhma9q2rkyp3w7hlw5szpj02-ormolu-0.7.2.0-bin", "default": true }, { "name": "out", - "path": "/nix/store/pnyfjx2mv5x5c7ic75694f9n6fks4mnk-ormolu-0.7.2.0" + "path": "/nix/store/v3n11ji64ibvggji9m8hq1cr6pl90b5k-ormolu-0.7.2.0" } ], - "store_path": "/nix/store/vlp9vbp2yibfcwpax8xp3yqfvagwm8sb-ormolu-0.7.2.0-bin" + "store_path": "/nix/store/31wjfy7cwhma9q2rkyp3w7hlw5szpj02-ormolu-0.7.2.0-bin" } } } diff --git a/package-lock.json b/package-lock.json index ffea6224..f7244b6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gren-lang", - "version": "0.4.5", + "version": "0.4.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gren-lang", - "version": "0.4.5", + "version": "0.4.6", "license": "BSD-3-Clause", "dependencies": { "postject": "^1.0.0-alpha.6" @@ -15,6 +15,7 @@ "gren": "cli.js" }, "devDependencies": { + "gren-lang": "0.4.5", "prettier": "3.3.3" } }, @@ -26,6 +27,16 @@ "node": "^12.20.0 || >=14" } }, + "node_modules/gren-lang": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/gren-lang/-/gren-lang-0.4.5.tgz", + "integrity": "sha512-++hR3fUqPNA59iMgqMDRKQW2NsoeXhx31kUjuJlUB9AUlBa3bvrfpFiiNprU4UHQF7fA/5eSctHQ9U+V5vAg4A==", + "dev": true, + "license": "BSD-3-Clause", + "bin": { + "gren": "index.js" + } + }, "node_modules/postject": { "version": "1.0.0-alpha.6", "resolved": "https://registry.npmjs.org/postject/-/postject-1.0.0-alpha.6.tgz", diff --git a/package.json b/package.json index 32747985..b24afc5d 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "gren-lang", - "version": "0.4.5", + "version": "0.4.6", "description": "Compiler for the Gren programming language", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "prepublishOnly": "gren make src/Main.gren --optimize --output=compiler.js", + "prepublishOnly": "npx --package=gren-lang@0.4.5 -- gren make src/Main.gren --optimize --output=compiler.js", "prettier": "prettier -w \"!**/*.json\" .", "prettier:check": "prettier -c \"!**/*.json\" ." }, @@ -39,6 +39,7 @@ "postject": "^1.0.0-alpha.6" }, "devDependencies": { - "prettier": "3.3.3" + "prettier": "3.3.3", + "gren-lang": "0.4.5" } }