From 7b5a372ad3cfccfdbf9c781422926c6f8de4df22 Mon Sep 17 00:00:00 2001 From: Alexander Wood Date: Sat, 1 Jun 2024 19:35:41 +0100 Subject: [PATCH 01/12] build(nix): Add `git-cliff` to devshell Refs: #22 --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index a0522c9..e4055c3 100644 --- a/flake.nix +++ b/flake.nix @@ -103,7 +103,6 @@ just-flake.features = { treefmt.enable = true; - convco.enable = true; }; @@ -156,6 +155,7 @@ pkgs.haskellPackages.haskell-debug-adapter pkgs.haskellPackages.ghci-dap pkgs.haskellPackages.hpack + pkgs.git-cliff ]; }; From b498ae36aaad575f2f375596fc67f8b6b4cfe713 Mon Sep 17 00:00:00 2001 From: Alexander Wood Date: Sat, 1 Jun 2024 20:16:38 +0100 Subject: [PATCH 02/12] build(changelog): Add cliff.toml --- cliff.toml | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 cliff.toml diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..cb41ef9 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,119 @@ +# git-cliff ~ default configuration file +# https://git-cliff.org/docs/configuration +# +# Lines starting with "#" are comments. +# Configuration options are organized into tables and keys. +# See documentation for more information on available options. + +[changelog] +# changelog header +header = """ +# Changelog\n +All notable changes to this project will be documented in this file.\n +Note that while Elara follows SemVer where possible, most of the source code is not considered public API with regards to breaking changes. +As such, breaking changes may occur between minor versions until a stable release of the language.\n +""" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{%- macro remote_url() -%} + https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }} +{%- endmacro -%} + +{% macro print_commit(commit) -%} + - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ + {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message | upper_first }} - \ + ([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\ + {% if commit.github.pr_number %} in #{{ commit.github.pr_number }}{%- endif %} \ +{% endmacro -%} + +{% if version %}\ + {% if previous.version %}\ + ## [{{ version | trim_start_matches(pat="v") }}]\ + ({{ self::remote_url() }}/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }} + {% else %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} + {% endif %}\ +{% else %}\ + ## [unreleased] +{% endif %}\ + +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits + | filter(attribute="scope") + | sort(attribute="scope") %} + {{ self::print_commit(commit=commit) }} + {%- endfor -%} + {% raw %}\n{% endraw %}\ + {%- for commit in commits %} + {%- if not commit.scope -%} + {{ self::print_commit(commit=commit) }} + {% endif -%} + {% endfor -%} +{% endfor %}\n +""" +# template for the changelog footer +footer = """ + +""" +# remove the leading and trailing s +trim = true +# postprocessors +postprocessors = [ + # { pattern = '', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL +] + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = false +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # Replace issue numbers + { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))"}, + # Check spelling of the commit with https://github.com/crate-ci/typos + # If the spelling is incorrect, it will be automatically fixed. + #{ pattern = '.*', replace_command = 'typos --write-changes -' }, +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^feat", group = "๐Ÿš€ Features" }, + { message = "^fix", group = "๐Ÿ› Bug Fixes" }, + { message = "^doc", group = "๐Ÿ“š Documentation" }, + { message = "^perf", group = "โšก Performance" }, + { message = "^refactor", group = "๐Ÿšœ Refactor" }, + { message = "^style", group = "๐ŸŽจ Styling" }, + { message = "^test", group = "๐Ÿงช Testing" }, + { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(deps.*\\)", skip = true }, + { message = "^chore\\(pr\\)", skip = true }, + { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore|^ci", group = "โš™๏ธ Miscellaneous Tasks" }, + { body = ".*security", group = "๐Ÿ›ก๏ธ Security" }, + { message = "^revert", group = "โ—€๏ธ Revert" }, +] +# protect breaking changes from being skipped due to matching a skipping commit_parser +protect_breaking_commits = false +# filter out the commits that are not matched by commit parsers +filter_commits = false +# regex for matching git tags +# tag_pattern = "v[0-9].*" +# regex for skipping tags +# skip_tags = "" +# regex for ignoring tags +# ignore_tags = "" +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest" +# limit the number of commits included in the changelog. +# limit_commits = 42 + +[remote.github] +owner="elaralang" +repo="elara" \ No newline at end of file From 9356157d672d7c5f2e402e835a0947e25cf32d03 Mon Sep 17 00:00:00 2001 From: Alexander Wood Date: Sat, 1 Jun 2024 20:16:58 +0100 Subject: [PATCH 03/12] docs(changelog): Use the git-cliff format for current changelog --- CHANGELOG.md | 449 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 280 insertions(+), 169 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37eeba1..52f8c63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,171 +1,282 @@ # Changelog -### [v0.0.2](https://github.com/ElaraLang/elara/compare/v0.0.1...v0.0.2) (2024-06-01) - -#### Features - -* **renamer:** Add a nice pretty error report for when the renamer catches -ambiguous names -([f31a6cd](https://github.com/ElaraLang/elara/commit/f31a6cd94be1e86fcd419fcc2d0a47b79e08e086)) - -#### Fixes - -* **renamer:** Fix heavy-handed ambiguous name checking reporting ambiguity -when there actually isn't any! Fixes variable shadowing -([ecb3481](https://github.com/ElaraLang/elara/commit/ecb3481cd8580e8b1ac9cfca42413f0996e5ad81)) - -#### Other - -* **renamer:** Change renaming backend to allow multiple names with the same -unqualified name -([f61f155](https://github.com/ElaraLang/elara/commit/f61f155c4f2c57e069ff82fa1cf7149d69d0dbdf)) - -#### Documentation - -* **changelog:** Update CHANGELOG.md -([0882b33](https://github.com/ElaraLang/elara/commit/0882b339938554cd083a197b1a4b7092f23b905c)) - -### [v0.0.1](https://github.com/ElaraLang/elara/compare/v0.0.0...v0.0.1) (2024-06-01) - -#### Features - -* **tocore:** Improve reporting of `UnknownConstructor` error in ToCore -([8fda8b3](https://github.com/ElaraLang/elara/commit/8fda8b31a101f0e70c70e5cdd21ae9967f475a66)) -* **stdlib:** Add Option module to stdlib -([646f1ae](https://github.com/ElaraLang/elara/commit/646f1aefa5b2e6d9ef88c4401acfac24b91369e7)) -* **stdlib:** Load all the stdlib files dynamically based on what's in the new -stdlib folder -([47e0e90](https://github.com/ElaraLang/elara/commit/47e0e90b71f41d830fe269f7cb99224ef7c0b1b9)) - -#### Fixes - -* **tocore:** Fix ToCore not being invoked in topological order, causing -unknown name errors -([8737b28](https://github.com/ElaraLang/elara/commit/8737b281c63b8b59055d0c3d1d319f8c31a41119)) - -#### Other - -* **actions:** that seemed to work - now remove the logging -([31478e6](https://github.com/ElaraLang/elara/commit/31478e679894b86feb899a8fa50e3b18babde244)) -* **actions:** Log big files -([282fb34](https://github.com/ElaraLang/elara/commit/282fb34aec3685f45f1a086d3a4fc418a1412624)) -* **actions:** nevermind let's not do that -([a30d954](https://github.com/ElaraLang/elara/commit/a30d954a686e116764c127e77b0b9d228af40a3c)) -* **actions:** Run linux builds on self-hosted runner -([9f8f291](https://github.com/ElaraLang/elara/commit/9f8f291e6e3dab4d50b3682a02e9b7a0c2c6fb42)) -* **actions:** Remove blank line -([20b7d8a](https://github.com/ElaraLang/elara/commit/20b7d8a958a29db2a324fc8987980873f8270807)) -* **actions:** Change the script...? -([4ab2c8f](https://github.com/ElaraLang/elara/commit/4ab2c8fa44b3aa0f910bced1b8e663c853594d99)), -closes [#19](https://github.com/ElaraLang/elara/issues/19) -* **actions:** Try deleting this folder -([c35171c](https://github.com/ElaraLang/elara/commit/c35171c71d049f4b468ceedea39f97c8407cbcaf)) -* **stdlib:** Make main file a bit more fully-fledged -([32b919c](https://github.com/ElaraLang/elara/commit/32b919c8358bb844b74228c2148dac3cd53a94d0)) -* **stdlib:** Move all stdlib files into new folder -([e7cd134](https://github.com/ElaraLang/elara/commit/e7cd1344aa8c04dafc79c2ff8f537985cc62708c)) - -## v0.0.0 (2024-06-01) - -### โš  BREAKING CHANGE - -* stdlib signature changed - - -### Features - -* **type-infer:** Add a new error message in the case of multiple tyapps being -detected (which shouldn't happen?) -([7486ea1](https://github.com/ElaraLang/elara/commit/7486ea12c758a85334ff48556be6365bc63302fa)) -* **logging:** Determine the log level based on elaraDebug variable -([93f8f8a](https://github.com/ElaraLang/elara/commit/93f8f8aefbe115ccd7bedaac3a404d15e3ececce)) -* **pretty-printing:** Remove the domain when printing foralls (as it will -only ever be type) -([2b5158e](https://github.com/ElaraLang/elara/commit/2b5158e3eb9459fb67079669025794a7fa81910a)) -* **pretty-printing:** Improve colourisation of pretty-printer output -([28492c5](https://github.com/ElaraLang/elara/commit/28492c57370c98ea8142574261dc36d1b80185b9)) -* **stdlib:** Add primitive functions for working with strings -([a582f06](https://github.com/ElaraLang/elara/commit/a582f0619b44bd20fc8fbbcfef4c744eb06a58fb)) -* **stdlib:** Restore the stdlib to its former glo -([0fc83e9](https://github.com/ElaraLang/elara/commit/0fc83e918b2ecf1422cf08c226d7f49442f175b7)) - -### Fixes - -* **type-infer:** Improve algorithm for detecting tyapps, fixing some edge -cases -([8503c23](https://github.com/ElaraLang/elara/commit/8503c23109a8f79180a70b77393040141d6527df)) -* **codegen:** Fix stringLength primitive not boxing integers -([85fcf5a](https://github.com/ElaraLang/elara/commit/85fcf5a6e72d2cd27f68c0854de3bf54e7b54b80)) -* **logging:** Remove old debugPretty calls -([64edc03](https://github.com/ElaraLang/elara/commit/64edc0310f539740bc81138b6b042b9333501617)) -* **type-infer:** Fix if/else type inference not always unifying correctly and -throwing errors -([33a72c2](https://github.com/ElaraLang/elara/commit/33a72c2103a1657dc9626176c2eb683513e9d4bf)) -* **tests:** Fix unit tests not compiling for various reasons -([e0a2955](https://github.com/ElaraLang/elara/commit/e0a2955d618e7a6ea1d244d2cf4672fb476c51ed)) -* **type-infer:** Fix type inference logging _always_ being on debug -([3b34bb1](https://github.com/ElaraLang/elara/commit/3b34bb1e216fafad98cf08c1d0dec4f242b61587)) -* **type-infer:** Fix constructor patterns not being completely solved -([1dc7624](https://github.com/ElaraLang/elara/commit/1dc7624f1dbaeab084a4fb7e3ae23170eb92337a)) -* **type-infer:** Fix conversion between types when explicitly applying type -constructors (eg `def x : Option Int`) -([940e960](https://github.com/ElaraLang/elara/commit/940e9608a699d06b9324f169cc1367afc43907d9)) -* Fix code generation for constructor patterns with multiple arguments -breaking -([6de3e20](https://github.com/ElaraLang/elara/commit/6de3e203a2d6ac90b98e7aea835062189a717621)) -* **type-infer:** Fix constructor pattern arguments being reversed in type -inference -([321fdd6](https://github.com/ElaraLang/elara/commit/321fdd6fbe6aaad25a547006d753a97f616e18d9)) - -### Other - -* **actions:** that seemed to work - now remove the logging -([f9a9294](https://github.com/ElaraLang/elara/commit/f9a9294cc28589d3204c5c1e3c4e84f0a95764cf)) -* **actions:** Log big files -([e0158fd](https://github.com/ElaraLang/elara/commit/e0158fd46eb94fcaaf9df45b06dd4ceb8526e4fc)) -* **actions:** nevermind let's not do that -([c684cb9](https://github.com/ElaraLang/elara/commit/c684cb95ab3c53c4a2508ccc8a8b676b5c6f7cc7)) -* **actions:** Run linux builds on self-hosted runner -([e47fa1a](https://github.com/ElaraLang/elara/commit/e47fa1acbdc2e180788bd8c008331baaa665392a)) -* **actions:** Remove blank line -([9b61673](https://github.com/ElaraLang/elara/commit/9b6167309e788bcaa4adc40493db610ef88a70c3)) -* **actions:** Change the script...? -([27dc8ea](https://github.com/ElaraLang/elara/commit/27dc8eaac5a23a955ae7336e96320b95663906d2)), -closes [#19](https://github.com/ElaraLang/elara/issues/19) -* **actions:** Try deleting this folder -([fb8c8bd](https://github.com/ElaraLang/elara/commit/fb8c8bd56ee9b231b39e1004123883934913c0a6)) -* **stdlib:** Change `readFile` to return String rather than EList -([01f4048](https://github.com/ElaraLang/elara/commit/01f40486c687c47d8f17a7795931d65c4f606e11)) -* **type-infer:** Uncomment test for `forall a. a` tyapps -([e2786a0](https://github.com/ElaraLang/elara/commit/e2786a056b7ab8ba46b96616cc953f6da3e84736)) -* **stdlib:** Remove random list from main file -([85524a1](https://github.com/ElaraLang/elara/commit/85524a108d84963b0b7090093ffb952e9d4ff4f8)) -* **type-infer:** Add new tests for type application insertion -([a341c65](https://github.com/ElaraLang/elara/commit/a341c6597677d6ff814d73cd6896231e7ed3f8b4)) -* **nix:** Update nix flake -([f95de02](https://github.com/ElaraLang/elara/commit/f95de028cc2349f71901f8c5c7e7b0cd8e4b1558)) -* **stdlib:** Refactor Elara Stdlib and add list length function -([2fa03be](https://github.com/ElaraLang/elara/commit/2fa03be4f9acc294bc2d0a41f5314fb9aceba625)) -* **stdlib:** Move ALL mentions of lists to the stdlib - they are no longer a -primitive! -([8e3d367](https://github.com/ElaraLang/elara/commit/8e3d367d94078552ea642851654c7abe7b7ff42e)) -* **logging:** Change back to info logging (really need to make this -configurable at runtime) -([7666ae9](https://github.com/ElaraLang/elara/commit/7666ae96126238a5f453a4462aedb692d0316093)) -* **tocore:** Change weird usage of =<< in ToCore -([936ab2a](https://github.com/ElaraLang/elara/commit/936ab2a3ec0b740fabae2c0954cc29d1f4cb4b24)) -* Begin work refactoring lambda generation - keep track of parameter names -_eerywhere_ -([9f8ed70](https://github.com/ElaraLang/elara/commit/9f8ed708d95cab1b5106606d15e96aa9d3aecd91)) -* Slightly tidy up generation of lambdas -([4654676](https://github.com/ElaraLang/elara/commit/4654676b73c2fa3258d9b3bf044f56e7a2f6e677)) -* **nix:** Add the old mission-control scripts back to the justfile -([1508631](https://github.com/ElaraLang/elara/commit/15086319ecb703d2774a436775312f7409df0489)) -* **nix:** Move from mission-control to just -([ba41767](https://github.com/ElaraLang/elara/commit/ba4176752274ae6b6cdbc870d8bc1d808378380d)) - -### Documentation - -* **stdlib:** Remove mention of EList from readme compiling guide -([624a156](https://github.com/ElaraLang/elara/commit/624a156569ef71567788a0d380ea13212dd5d9c5)), -closes [#12](https://github.com/ElaraLang/elara/issues/12) +All notable changes to this project will be documented in this file. + +Note that while Elara follows SemVer where possible, most of the source code is not considered public API with regards to breaking changes. +As such, breaking changes may occur between minor versions until a stable release of the language. + +## [unreleased] + +### ๐Ÿ“š Documentation + +- *(changelog)* Update CHANGELOG.md - ([31c62a7](https://github.com/elaralang/elara/commit/31c62a74c4273f360f1b8cbb88a57c166ae942c9)) + +### ๐Ÿงช Testing + +- *(shunter)* Fix shunting tests no longer compiling - ([4e9d196](https://github.com/elaralang/elara/commit/4e9d196c4ab64695f7c0c2440abf5a90ddfa8f8d)) + +### Build + +- *(nix)* Add `git-cliff` to devshell - ([8a6187e](https://github.com/elaralang/elara/commit/8a6187e4038f9dc73e756983c6abd9aaec4eb4d9)) + +## [0.0.2](https://github.com/elaralang/elara/compare/v0.0.1..v0.0.2) - 2024-06-01 + +### ๐Ÿš€ Features + +- *(renamer)* Add a nice pretty error report for when the renamer catches ambiguous names - ([f31a6cd](https://github.com/elaralang/elara/commit/f31a6cd94be1e86fcd419fcc2d0a47b79e08e086)) + +### ๐Ÿ› Bug Fixes + +- *(renamer)* Fix heavy-handed ambiguous name checking reporting ambiguity when there actually isn't any! Fixes variable shadowing - ([ecb3481](https://github.com/elaralang/elara/commit/ecb3481cd8580e8b1ac9cfca42413f0996e5ad81)) + +### ๐Ÿšœ Refactor + +- *(renamer)* Change renaming backend to allow multiple names with the same unqualified name - ([f61f155](https://github.com/elaralang/elara/commit/f61f155c4f2c57e069ff82fa1cf7149d69d0dbdf)) + +### ๐Ÿ“š Documentation + +- *(changelog)* Update CHANGELOG.md - ([0882b33](https://github.com/elaralang/elara/commit/0882b339938554cd083a197b1a4b7092f23b905c)) + +## [0.0.1](https://github.com/elaralang/elara/compare/v0.0.0..v0.0.1) - 2024-06-01 + +### ๐Ÿš€ Features + +- *(stdlib)* Load all the stdlib files dynamically based on what's in the new stdlib folder - ([47e0e90](https://github.com/elaralang/elara/commit/47e0e90b71f41d830fe269f7cb99224ef7c0b1b9)) +- *(stdlib)* Add Option module to stdlib - ([646f1ae](https://github.com/elaralang/elara/commit/646f1aefa5b2e6d9ef88c4401acfac24b91369e7)) +- *(tocore)* Improve reporting of `UnknownConstructor` error in ToCore - ([8fda8b3](https://github.com/elaralang/elara/commit/8fda8b31a101f0e70c70e5cdd21ae9967f475a66)) + +### ๐Ÿ› Bug Fixes + +- *(tocore)* Fix ToCore not being invoked in topological order, causing unknown name errors - ([8737b28](https://github.com/elaralang/elara/commit/8737b281c63b8b59055d0c3d1d319f8c31a41119)) + +### ๐Ÿšœ Refactor + +- *(stdlib)* Move all stdlib files into new folder - ([e7cd134](https://github.com/elaralang/elara/commit/e7cd1344aa8c04dafc79c2ff8f537985cc62708c)) + +### ๐ŸŽจ Styling + +- *(actions)* Remove blank line - ([20b7d8a](https://github.com/elaralang/elara/commit/20b7d8a958a29db2a324fc8987980873f8270807)) +- *(stdlib)* Make main file a bit more fully-fledged - ([32b919c](https://github.com/elaralang/elara/commit/32b919c8358bb844b74228c2148dac3cd53a94d0)) + +### โš™๏ธ Miscellaneous Tasks + +- *(actions)* Try deleting this folder - ([c35171c](https://github.com/elaralang/elara/commit/c35171c71d049f4b468ceedea39f97c8407cbcaf)) +- *(actions)* Change the script...? - ([4ab2c8f](https://github.com/elaralang/elara/commit/4ab2c8fa44b3aa0f910bced1b8e663c853594d99)) +- *(actions)* Run linux builds on self-hosted runner - ([9f8f291](https://github.com/elaralang/elara/commit/9f8f291e6e3dab4d50b3682a02e9b7a0c2c6fb42)) +- *(actions)* Nevermind let's not do that - ([a30d954](https://github.com/elaralang/elara/commit/a30d954a686e116764c127e77b0b9d228af40a3c)) +- *(actions)* Log big files - ([282fb34](https://github.com/elaralang/elara/commit/282fb34aec3685f45f1a086d3a4fc418a1412624)) +- *(actions)* That seemed to work - now remove the logging - ([31478e6](https://github.com/elaralang/elara/commit/31478e679894b86feb899a8fa50e3b18babde244)) + +## [0.0.0] - 2024-06-01 + +### ๐Ÿš€ Features + +- *(logging)* Determine the log level based on elaraDebug variable - ([93f8f8a](https://github.com/elaralang/elara/commit/93f8f8aefbe115ccd7bedaac3a404d15e3ececce)) +- *(pretty-printing)* Improve colourisation of pretty-printer output - ([28492c5](https://github.com/elaralang/elara/commit/28492c57370c98ea8142574261dc36d1b80185b9)) +- *(pretty-printing)* Remove the domain when printing foralls (as it will only ever be type) - ([2b5158e](https://github.com/elaralang/elara/commit/2b5158e3eb9459fb67079669025794a7fa81910a)) +- *(stdlib)* Restore the stdlib to its former glo - ([0fc83e9](https://github.com/elaralang/elara/commit/0fc83e918b2ecf1422cf08c226d7f49442f175b7)) +- *(stdlib)* Add primitive functions for working with strings - ([a582f06](https://github.com/elaralang/elara/commit/a582f0619b44bd20fc8fbbcfef4c744eb06a58fb)) +- *(type-infer)* Add a new error message in the case of multiple tyapps being detected (which shouldn't happen?) - ([7486ea1](https://github.com/elaralang/elara/commit/7486ea12c758a85334ff48556be6365bc63302fa)) + +### ๐Ÿ› Bug Fixes + +- *(codegen)* Fix stringLength primitive not boxing integers - ([85fcf5a](https://github.com/elaralang/elara/commit/85fcf5a6e72d2cd27f68c0854de3bf54e7b54b80)) +- *(logging)* Remove old debugPretty calls - ([64edc03](https://github.com/elaralang/elara/commit/64edc0310f539740bc81138b6b042b9333501617)) +- *(tests)* Fix unit tests not compiling for various reasons - ([e0a2955](https://github.com/elaralang/elara/commit/e0a2955d618e7a6ea1d244d2cf4672fb476c51ed)) +- *(type-infer)* Fix constructor pattern arguments being reversed in type inference - ([321fdd6](https://github.com/elaralang/elara/commit/321fdd6fbe6aaad25a547006d753a97f616e18d9)) +- *(type-infer)* Fix conversion between types when explicitly applying type constructors (eg `def x : Option Int`) - ([940e960](https://github.com/elaralang/elara/commit/940e9608a699d06b9324f169cc1367afc43907d9)) +- *(type-infer)* Fix constructor patterns not being completely solved - ([1dc7624](https://github.com/elaralang/elara/commit/1dc7624f1dbaeab084a4fb7e3ae23170eb92337a)) +- *(type-infer)* Fix type inference logging _always_ being on debug - ([3b34bb1](https://github.com/elaralang/elara/commit/3b34bb1e216fafad98cf08c1d0dec4f242b61587)) +- *(type-infer)* Fix if/else type inference not always unifying correctly and throwing errors - ([33a72c2](https://github.com/elaralang/elara/commit/33a72c2103a1657dc9626176c2eb683513e9d4bf)) +- *(type-infer)* Improve algorithm for detecting tyapps, fixing some edge cases - ([8503c23](https://github.com/elaralang/elara/commit/8503c23109a8f79180a70b77393040141d6527df)) +- Fix the tests + - ([1273624](https://github.com/elaralang/elara/commit/1273624f5efd8a4dc9a52df073e199c03a180874)) +- Fix name shadowing in inspection + - ([56dc353](https://github.com/elaralang/elara/commit/56dc3534dfa22b5aee0582788784570c7560486e)) +- Fix haddock comment + - ([945cd39](https://github.com/elaralang/elara/commit/945cd398eaccb880d36017ba8f06279ba93880ae)) +- Fix latex + - ([57cb4ac](https://github.com/elaralang/elara/commit/57cb4ac62336eea9cddb65e24c730b70d3533801)) +- Fix a bunch of warnings :D + - ([bef63d7](https://github.com/elaralang/elara/commit/bef63d70b55ed5e988bd822513df2ed95c44bdde)) +- Fix some more warnings + - ([ea6b295](https://github.com/elaralang/elara/commit/ea6b295a211c57609665f2c23833578738d485a2)) +- Fix more warnings + - ([877fa2d](https://github.com/elaralang/elara/commit/877fa2df71692775c9cba46f92c361fae38b747b)) +- Fix a naughty parser edge case, but now indentation is broken + - ([fb64659](https://github.com/elaralang/elara/commit/fb646599f65db122aa30e5cea8a250e055de5429)) +- Fix local let bindings not being annotated properly + - ([5437b1b](https://github.com/elaralang/elara/commit/5437b1bc0f789b89090689919a0cda3e3f873684)) +- Fix parsing tests, make let-binding names unqualified + - ([16221a2](https://github.com/elaralang/elara/commit/16221a2b96fd9ddf7dc6e80b1523c8ae08376253)) +- Fix funny quickcheck edge cases + - ([c231e2a](https://github.com/elaralang/elara/commit/c231e2ac6872efe1d4aac5590087f6f01c0ea446)) +- Fix some haddock typos + - ([543a982](https://github.com/elaralang/elara/commit/543a982fb6c6c2bb9e288465ace248b64eb73ba0)) +- Fix let-in error + - ([9b60ec8](https://github.com/elaralang/elara/commit/9b60ec83ea45e08cfd022832c64c890a0f748a88)) +- Fix prettyprint infinite loop lol + - ([ace5c19](https://github.com/elaralang/elara/commit/ace5c19e65adf51e119efa3af67a99eaa8addc66)) +- Fix unification with type declarations + - ([24e2278](https://github.com/elaralang/elara/commit/24e2278773432462e072d1e412e530ac30d52026)) +- Fix da nix + - ([7ed19ef](https://github.com/elaralang/elara/commit/7ed19ef155b2f56e03544e06de7bdef3ac6aeee4)) +- Fix da stack (doesnt rhyme sorry) + - ([79018aa](https://github.com/elaralang/elara/commit/79018aabb9594ee3aef344f8b92c03fbba2b1583)) +- Fix type inference? + - ([b05c98a](https://github.com/elaralang/elara/commit/b05c98a9ff0afeabb47155c88ab6c1643253c3fd)) +- Fix hie + - ([2b53f88](https://github.com/elaralang/elara/commit/2b53f88ee07827d67cf0c7ccce5520ffeb38b7bc)) +- Fix unit tests + - ([2ef17dd](https://github.com/elaralang/elara/commit/2ef17dd60ebfabbec9f05a7b67fcfb2528e02db2)) +- Fix doctests + - ([f2543c7](https://github.com/elaralang/elara/commit/f2543c7bd40427ad91488df1dc959d6df58c8774)) +- Fix the pattern parser & add a lot of tests + - ([94d1669](https://github.com/elaralang/elara/commit/94d1669fa7c151d4d36964fa3a05ca185173cb1b)) +- Fix lots of bugs! + - ([438e69f](https://github.com/elaralang/elara/commit/438e69f744c68b730aa625e891e593d57a5aaff7)) +- Fix subtyping on custom types + - ([c790d2f](https://github.com/elaralang/elara/commit/c790d2f756aef3386a5f54ff8fd32898f11dbd27)) +- Fix stupid ugly CI (maybe) + - ([ad7a872](https://github.com/elaralang/elara/commit/ad7a87227ce7a506a5903c228ea390f17fb517e7)) +- Fix some warnings and refactor even more + - ([1d96b4d](https://github.com/elaralang/elara/commit/1d96b4d7d96379084a914f3d8090bf4de9078be1)) +- Fix a morbillion more warnings + - ([be1c891](https://github.com/elaralang/elara/commit/be1c891aadf9850bb817aa0aaca5216b1ba6568b)) +- Fix almost all the warnings + - ([351f7fb](https://github.com/elaralang/elara/commit/351f7fb55ed24254401eb88894cc790719a3069d)) +- Fix a very rare lexer edge case + - ([b0369fc](https://github.com/elaralang/elara/commit/b0369fcc435934d20876ae0dd08e0c165acc8e11)) +- Fix build error + - ([c154b25](https://github.com/elaralang/elara/commit/c154b25657399e75d675761e97f0baf597714dbb)) +- Fix the tests not compiling (oops) + - ([4a620ee](https://github.com/elaralang/elara/commit/4a620ee9f3549ce4592ca06a88cfe8f57b9497a4)) +- Fix the tests not compiling (oops) + - ([4ff8661](https://github.com/elaralang/elara/commit/4ff8661e822452390a0ebc402a7055c152a638f8)) +- Fix let-in constructs being given the wrong type in core + - ([e52396e](https://github.com/elaralang/elara/commit/e52396e44274be57da41a52fe7189040cbd40a57)) +- Fix maxLocals for + - ([1a09f30](https://github.com/elaralang/elara/commit/1a09f30c220e563ca60d2d610e7b7ab65838a580)) +- Fix bug in renaming let statements + - ([4825d10](https://github.com/elaralang/elara/commit/4825d102860a0a61c8dae696875b42cff7eb6c44)) +- Fix the cons type + - ([8813151](https://github.com/elaralang/elara/commit/8813151a17505b3224514a429c93df1220e03302)) +- Fix parse error with higher order functions + - ([4452451](https://github.com/elaralang/elara/commit/44524515c89c7a84dd3578228fee0c609a539b04)) +- Fix unnecessary type applications being added + - ([09dc4ba](https://github.com/elaralang/elara/commit/09dc4ba5e96d93dc09cebe79a170815b0c479d4a)) +- Fix variables in ToCore using the wrong types + - ([d3da4bb](https://github.com/elaralang/elara/commit/d3da4bb60b3ee3e376b19939fa067a85819aae95)) +- Fix (?) type inference for list literals + - ([8a20d85](https://github.com/elaralang/elara/commit/8a20d856748c3472b488fa719b3c117074a5b07f)) +- Fix CI + - ([34bbcb0](https://github.com/elaralang/elara/commit/34bbcb0fe09c74121a723c2da76c6aff86e3887c)) +- Fix undefined handling + - ([85a0df4](https://github.com/elaralang/elara/commit/85a0df48b54f9cb6e76ff487150f840d0a4d1cdc)) +- Fix |> and emitting higher order functions + - ([69b3236](https://github.com/elaralang/elara/commit/69b3236708023b15ea9aed0b011d324bf7990ae5)) +- Fix more tyapps + - ([70aae06](https://github.com/elaralang/elara/commit/70aae06edb2a4ea2ebdcc31707532b1a68624ff3)) +- Fix redundant pattern match warning with Local' & Global' + - ([cd0ca0c](https://github.com/elaralang/elara/commit/cd0ca0c8b7982a9083c20ea2adfbfed25ad1a331)) +- Fix core type instantiation being incorrect + - ([97427ab](https://github.com/elaralang/elara/commit/97427ab1a7731e19bb4ccec1170c5f4350158e0a)) +- Fix match expressions inferring to the wrong type + - ([ad97cef](https://github.com/elaralang/elara/commit/ad97cefc9f91e5385977692e78b78b83974825d1)) +- Fix ci running + - ([a858457](https://github.com/elaralang/elara/commit/a8584571399ee3ff27f7fcae80546b012a5945eb)) +- Fix shunt tests + - ([d017534](https://github.com/elaralang/elara/commit/d017534f7c17767811bd2663d4167d2b8a30b782)) +- Fix a bunch of warnings + - ([aa811c7](https://github.com/elaralang/elara/commit/aa811c7ccc41b085aa58a78cdeb59bfbf57762fe)) +- Fix the unit tests compiling + - ([b2e838d](https://github.com/elaralang/elara/commit/b2e838dc9ee35e6a9f8abb7a9a01064904d1c682)) +- Fix all tests + - ([216af73](https://github.com/elaralang/elara/commit/216af73edfeb5da214999f961bcbc52bdc73591b)) +- Fix gh workflow + - ([143afe5](https://github.com/elaralang/elara/commit/143afe5adb1f55a401bcdd4cda9a545d12e5828f)) +- Fix order of lambda params + - ([34b992c](https://github.com/elaralang/elara/commit/34b992c8b58d478dbacf68e54398ecbaa7d384eb)) +- Fix weird deveshell bug + - ([018ad04](https://github.com/elaralang/elara/commit/018ad047f2573e477a51b63b0058a554ef5fcc7a)) +- Fix Show instance for UniqueID + - ([69abce6](https://github.com/elaralang/elara/commit/69abce637f21705340360d45bb5b247826c50aa9)) +- Fix a bunch of warnings + - ([ca5bada](https://github.com/elaralang/elara/commit/ca5badadb5429e8eea76dee44db34eb2aa4bbef0)) +- Fix tests too + - ([8ac8089](https://github.com/elaralang/elara/commit/8ac8089176bc12bea0878ab39e202a6a2252c289)) +- Fix unix build + - ([02d1936](https://github.com/elaralang/elara/commit/02d1936da432f7fe6c75bfe28c9898fab7e25509)) +- Fix crlf endings breaking lexer + - ([5c23b0c](https://github.com/elaralang/elara/commit/5c23b0cc250289fcd99b224df6f54fd34fd559a1)) +- Fix unit tests + - ([164dc28](https://github.com/elaralang/elara/commit/164dc284d4d83ecb063bd8208f036811f3f5fed9)) +- Fix jvm separator on windows + - ([59674d7](https://github.com/elaralang/elara/commit/59674d7c3bf625dc84c8176d43aa0034b198cbb7)) +- Fix parsing of constructor patterns with args without parens + - ([aadac49](https://github.com/elaralang/elara/commit/aadac49e00acf5d3e60b13bef214be081f38b919)) +- Fix graph topology due from constructor patterns + - ([5184f39](https://github.com/elaralang/elara/commit/5184f393679f5b66a4f3ac5357a5439382f3cfe8)) +- Fix constructors with multiple fields being invalidly generated + - ([6fd72ae](https://github.com/elaralang/elara/commit/6fd72ae0a78a4aabf87112f7e81741669f7b6a05)) +- Fix wrong toString append being used + - ([a668e0a](https://github.com/elaralang/elara/commit/a668e0a3530bc5a264e16a15a42ee58e6dabb4f0)) +- Fix adt match calling in the wrong order + - ([a396b22](https://github.com/elaralang/elara/commit/a396b224f317bd16b17ce88e849f5c1a4a2ce0ce)) +- Fix type / kind inference and such + - ([49fcb62](https://github.com/elaralang/elara/commit/49fcb624a679122d726b5c7b08685b86f6d4a127)) +- Fix the prettyprinter changes breaking the unit tests + - ([207856e](https://github.com/elaralang/elara/commit/207856e27346683d85001b2ad8cbb49c66d6b618)) +- Fix code generation for constructor patterns with multiple arguments breaking - ([6de3e20](https://github.com/elaralang/elara/commit/6de3e203a2d6ac90b98e7aea835062189a717621)) + +### ๐Ÿšœ Refactor + +- *(stdlib)* Move ALL mentions of lists to the stdlib - they are no longer a primitive! - ([8e3d367](https://github.com/elaralang/elara/commit/8e3d367d94078552ea642851654c7abe7b7ff42e)) +- *(stdlib)* Refactor Elara Stdlib and add list length function - ([2fa03be](https://github.com/elaralang/elara/commit/2fa03be4f9acc294bc2d0a41f5314fb9aceba625)) +- *(stdlib)* [**breaking**] Change `readFile` to return String rather than EList - ([01f4048](https://github.com/elaralang/elara/commit/01f40486c687c47d8f17a7795931d65c4f606e11)) +- Refactor tests + - ([8151cfd](https://github.com/elaralang/elara/commit/8151cfde6fec3c8cc106c20ce0ffc7885a507f63)) +- Refactors + - ([718aa8a](https://github.com/elaralang/elara/commit/718aa8aa8e3f4a33ede2375f3854c7a33e6948cc)) +- Refactor HasDependencies to allow multiple keys + - ([5d1490e](https://github.com/elaralang/elara/commit/5d1490e75e41ad492164850c909a7c96fb2c9619)) +- Refactor how type constructors are handled in core + - ([ba962be](https://github.com/elaralang/elara/commit/ba962be52873f8093166170256650c681b48c715)) +- Slightly tidy up generation of lambdas - ([4654676](https://github.com/elaralang/elara/commit/4654676b73c2fa3258d9b3bf044f56e7a2f6e677)) +- Begin work refactoring lambda generation - keep track of parameter names _eerywhere_ - ([9f8ed70](https://github.com/elaralang/elara/commit/9f8ed708d95cab1b5106606d15e96aa9d3aecd91)) + +### ๐Ÿ“š Documentation + +- *(stdlib)* Remove mention of EList from readme compiling guide - ([624a156](https://github.com/elaralang/elara/commit/624a156569ef71567788a0d380ea13212dd5d9c5)) +- Document the pipeline a bit + - ([efd41ea](https://github.com/elaralang/elara/commit/efd41ea37b869d5249de26cf3eee44fb6176915c)) + +### ๐ŸŽจ Styling + +- *(actions)* Remove blank line - ([9b61673](https://github.com/elaralang/elara/commit/9b6167309e788bcaa4adc40493db610ef88a70c3)) +- *(tocore)* Change weird usage of =<< in ToCore - ([936ab2a](https://github.com/elaralang/elara/commit/936ab2a3ec0b740fabae2c0954cc29d1f4cb4b24)) + +### ๐Ÿงช Testing + +- *(type-infer)* Add new tests for type application insertion - ([a341c65](https://github.com/elaralang/elara/commit/a341c6597677d6ff814d73cd6896231e7ed3f8b4)) +- *(type-infer)* Uncomment test for `forall a. a` tyapps - ([e2786a0](https://github.com/elaralang/elara/commit/e2786a056b7ab8ba46b96616cc953f6da3e84736)) +- Test - ([dd1a893](https://github.com/elaralang/elara/commit/dd1a8930c50658d46009a6690db05244acd81532)) + +### โš™๏ธ Miscellaneous Tasks + +- *(actions)* Try deleting this folder - ([fb8c8bd](https://github.com/elaralang/elara/commit/fb8c8bd56ee9b231b39e1004123883934913c0a6)) +- *(actions)* Change the script...? - ([27dc8ea](https://github.com/elaralang/elara/commit/27dc8eaac5a23a955ae7336e96320b95663906d2)) +- *(actions)* Run linux builds on self-hosted runner - ([e47fa1a](https://github.com/elaralang/elara/commit/e47fa1acbdc2e180788bd8c008331baaa665392a)) +- *(actions)* Nevermind let's not do that - ([c684cb9](https://github.com/elaralang/elara/commit/c684cb95ab3c53c4a2508ccc8a8b676b5c6f7cc7)) +- *(actions)* Log big files - ([e0158fd](https://github.com/elaralang/elara/commit/e0158fd46eb94fcaaf9df45b06dd4ceb8526e4fc)) +- *(actions)* That seemed to work - now remove the logging - ([f9a9294](https://github.com/elaralang/elara/commit/f9a9294cc28589d3204c5c1e3c4e84f0a95764cf)) +- *(logging)* Change back to info logging (really need to make this configurable at runtime) - ([7666ae9](https://github.com/elaralang/elara/commit/7666ae96126238a5f453a4462aedb692d0316093)) +- *(nix)* Move from mission-control to just - ([ba41767](https://github.com/elaralang/elara/commit/ba4176752274ae6b6cdbc870d8bc1d808378380d)) +- *(nix)* Add the old mission-control scripts back to the justfile - ([1508631](https://github.com/elaralang/elara/commit/15086319ecb703d2774a436775312f7409df0489)) +- *(stdlib)* Remove random list from main file - ([85524a1](https://github.com/elaralang/elara/commit/85524a108d84963b0b7090093ffb952e9d4ff4f8)) + +### Build + +- *(nix)* Update nix flake - ([f95de02](https://github.com/elaralang/elara/commit/f95de028cc2349f71901f8c5c7e7b0cd8e4b1558)) + + From bdbcfb900923116c535d046a99b1d1f6d4323864 Mon Sep 17 00:00:00 2001 From: Alexander Wood Date: Sat, 1 Jun 2024 20:24:20 +0100 Subject: [PATCH 04/12] ci(cd): Add action to generate changelogs whenever you push to main --- .github/workflows/cd.yaml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/cd.yaml diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 0000000..3ff9d9f --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,32 @@ +name: "CD" +on: + push: + branches: + - "master" +jobs: + changelog: + name: Generate changelog + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Generate a changelog + uses: orhun/git-cliff-action@v3 + with: + config: cliff.toml + args: --verbose + env: + OUTPUT: CHANGELOG.md + GITHUB_REPO: ${{ github.repository }} + + - name: Commit + run: | + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + set +e + git add CHANGELOG.md + git commit -m "Update changelog" + git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git master From 7101456975eb1617c3e2c2241b3adb58ad0ddd45 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 1 Jun 2024 19:27:13 +0000 Subject: [PATCH 05/12] Update changelog --- CHANGELOG.md | 274 ++++++++++++++++++++++++++------------------------- 1 file changed, 140 insertions(+), 134 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52f8c63..9c2d683 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,274 +9,280 @@ As such, breaking changes may occur between minor versions until a stable releas ### ๐Ÿ“š Documentation -- *(changelog)* Update CHANGELOG.md - ([31c62a7](https://github.com/elaralang/elara/commit/31c62a74c4273f360f1b8cbb88a57c166ae942c9)) +- *(changelog)* Update CHANGELOG.md - ([31c62a7](https://github.com/ElaraLang/elara/commit/31c62a74c4273f360f1b8cbb88a57c166ae942c9)) +- *(changelog)* Use the git-cliff format for current changelog - ([f52b80b](https://github.com/ElaraLang/elara/commit/f52b80b26ba811767b4c0e4cc7059b8c24df8601)) ### ๐Ÿงช Testing -- *(shunter)* Fix shunting tests no longer compiling - ([4e9d196](https://github.com/elaralang/elara/commit/4e9d196c4ab64695f7c0c2440abf5a90ddfa8f8d)) +- *(shunter)* Fix shunting tests no longer compiling - ([4e9d196](https://github.com/ElaraLang/elara/commit/4e9d196c4ab64695f7c0c2440abf5a90ddfa8f8d)) + +### โš™๏ธ Miscellaneous Tasks + +- *(cd)* Add action to generate changelogs whenever you push to main - ([cea8bae](https://github.com/ElaraLang/elara/commit/cea8bae0ec2d7fba47b7831ac720f8cc21fce308)) ### Build -- *(nix)* Add `git-cliff` to devshell - ([8a6187e](https://github.com/elaralang/elara/commit/8a6187e4038f9dc73e756983c6abd9aaec4eb4d9)) +- *(changelog)* Add cliff.toml - ([682cc9f](https://github.com/ElaraLang/elara/commit/682cc9f771b49de35f2f4d70f4829d2e4bd31523)) +- *(nix)* Add `git-cliff` to devshell - ([8a6187e](https://github.com/ElaraLang/elara/commit/8a6187e4038f9dc73e756983c6abd9aaec4eb4d9)) -## [0.0.2](https://github.com/elaralang/elara/compare/v0.0.1..v0.0.2) - 2024-06-01 +## [0.0.2](https://github.com/ElaraLang/elara/compare/v0.0.1..v0.0.2) - 2024-06-01 ### ๐Ÿš€ Features -- *(renamer)* Add a nice pretty error report for when the renamer catches ambiguous names - ([f31a6cd](https://github.com/elaralang/elara/commit/f31a6cd94be1e86fcd419fcc2d0a47b79e08e086)) +- *(renamer)* Add a nice pretty error report for when the renamer catches ambiguous names - ([f31a6cd](https://github.com/ElaraLang/elara/commit/f31a6cd94be1e86fcd419fcc2d0a47b79e08e086)) ### ๐Ÿ› Bug Fixes -- *(renamer)* Fix heavy-handed ambiguous name checking reporting ambiguity when there actually isn't any! Fixes variable shadowing - ([ecb3481](https://github.com/elaralang/elara/commit/ecb3481cd8580e8b1ac9cfca42413f0996e5ad81)) +- *(renamer)* Fix heavy-handed ambiguous name checking reporting ambiguity when there actually isn't any! Fixes variable shadowing - ([ecb3481](https://github.com/ElaraLang/elara/commit/ecb3481cd8580e8b1ac9cfca42413f0996e5ad81)) ### ๐Ÿšœ Refactor -- *(renamer)* Change renaming backend to allow multiple names with the same unqualified name - ([f61f155](https://github.com/elaralang/elara/commit/f61f155c4f2c57e069ff82fa1cf7149d69d0dbdf)) +- *(renamer)* Change renaming backend to allow multiple names with the same unqualified name - ([f61f155](https://github.com/ElaraLang/elara/commit/f61f155c4f2c57e069ff82fa1cf7149d69d0dbdf)) ### ๐Ÿ“š Documentation -- *(changelog)* Update CHANGELOG.md - ([0882b33](https://github.com/elaralang/elara/commit/0882b339938554cd083a197b1a4b7092f23b905c)) +- *(changelog)* Update CHANGELOG.md - ([0882b33](https://github.com/ElaraLang/elara/commit/0882b339938554cd083a197b1a4b7092f23b905c)) -## [0.0.1](https://github.com/elaralang/elara/compare/v0.0.0..v0.0.1) - 2024-06-01 +## [0.0.1](https://github.com/ElaraLang/elara/compare/v0.0.0..v0.0.1) - 2024-06-01 ### ๐Ÿš€ Features -- *(stdlib)* Load all the stdlib files dynamically based on what's in the new stdlib folder - ([47e0e90](https://github.com/elaralang/elara/commit/47e0e90b71f41d830fe269f7cb99224ef7c0b1b9)) -- *(stdlib)* Add Option module to stdlib - ([646f1ae](https://github.com/elaralang/elara/commit/646f1aefa5b2e6d9ef88c4401acfac24b91369e7)) -- *(tocore)* Improve reporting of `UnknownConstructor` error in ToCore - ([8fda8b3](https://github.com/elaralang/elara/commit/8fda8b31a101f0e70c70e5cdd21ae9967f475a66)) +- *(stdlib)* Load all the stdlib files dynamically based on what's in the new stdlib folder - ([47e0e90](https://github.com/ElaraLang/elara/commit/47e0e90b71f41d830fe269f7cb99224ef7c0b1b9)) +- *(stdlib)* Add Option module to stdlib - ([646f1ae](https://github.com/ElaraLang/elara/commit/646f1aefa5b2e6d9ef88c4401acfac24b91369e7)) +- *(tocore)* Improve reporting of `UnknownConstructor` error in ToCore - ([8fda8b3](https://github.com/ElaraLang/elara/commit/8fda8b31a101f0e70c70e5cdd21ae9967f475a66)) ### ๐Ÿ› Bug Fixes -- *(tocore)* Fix ToCore not being invoked in topological order, causing unknown name errors - ([8737b28](https://github.com/elaralang/elara/commit/8737b281c63b8b59055d0c3d1d319f8c31a41119)) +- *(tocore)* Fix ToCore not being invoked in topological order, causing unknown name errors - ([8737b28](https://github.com/ElaraLang/elara/commit/8737b281c63b8b59055d0c3d1d319f8c31a41119)) ### ๐Ÿšœ Refactor -- *(stdlib)* Move all stdlib files into new folder - ([e7cd134](https://github.com/elaralang/elara/commit/e7cd1344aa8c04dafc79c2ff8f537985cc62708c)) +- *(stdlib)* Move all stdlib files into new folder - ([e7cd134](https://github.com/ElaraLang/elara/commit/e7cd1344aa8c04dafc79c2ff8f537985cc62708c)) ### ๐ŸŽจ Styling -- *(actions)* Remove blank line - ([20b7d8a](https://github.com/elaralang/elara/commit/20b7d8a958a29db2a324fc8987980873f8270807)) -- *(stdlib)* Make main file a bit more fully-fledged - ([32b919c](https://github.com/elaralang/elara/commit/32b919c8358bb844b74228c2148dac3cd53a94d0)) +- *(actions)* Remove blank line - ([20b7d8a](https://github.com/ElaraLang/elara/commit/20b7d8a958a29db2a324fc8987980873f8270807)) +- *(stdlib)* Make main file a bit more fully-fledged - ([32b919c](https://github.com/ElaraLang/elara/commit/32b919c8358bb844b74228c2148dac3cd53a94d0)) ### โš™๏ธ Miscellaneous Tasks -- *(actions)* Try deleting this folder - ([c35171c](https://github.com/elaralang/elara/commit/c35171c71d049f4b468ceedea39f97c8407cbcaf)) -- *(actions)* Change the script...? - ([4ab2c8f](https://github.com/elaralang/elara/commit/4ab2c8fa44b3aa0f910bced1b8e663c853594d99)) -- *(actions)* Run linux builds on self-hosted runner - ([9f8f291](https://github.com/elaralang/elara/commit/9f8f291e6e3dab4d50b3682a02e9b7a0c2c6fb42)) -- *(actions)* Nevermind let's not do that - ([a30d954](https://github.com/elaralang/elara/commit/a30d954a686e116764c127e77b0b9d228af40a3c)) -- *(actions)* Log big files - ([282fb34](https://github.com/elaralang/elara/commit/282fb34aec3685f45f1a086d3a4fc418a1412624)) -- *(actions)* That seemed to work - now remove the logging - ([31478e6](https://github.com/elaralang/elara/commit/31478e679894b86feb899a8fa50e3b18babde244)) +- *(actions)* Try deleting this folder - ([c35171c](https://github.com/ElaraLang/elara/commit/c35171c71d049f4b468ceedea39f97c8407cbcaf)) +- *(actions)* Change the script...? - ([4ab2c8f](https://github.com/ElaraLang/elara/commit/4ab2c8fa44b3aa0f910bced1b8e663c853594d99)) +- *(actions)* Run linux builds on self-hosted runner - ([9f8f291](https://github.com/ElaraLang/elara/commit/9f8f291e6e3dab4d50b3682a02e9b7a0c2c6fb42)) +- *(actions)* Nevermind let's not do that - ([a30d954](https://github.com/ElaraLang/elara/commit/a30d954a686e116764c127e77b0b9d228af40a3c)) +- *(actions)* Log big files - ([282fb34](https://github.com/ElaraLang/elara/commit/282fb34aec3685f45f1a086d3a4fc418a1412624)) +- *(actions)* That seemed to work - now remove the logging - ([31478e6](https://github.com/ElaraLang/elara/commit/31478e679894b86feb899a8fa50e3b18babde244)) ## [0.0.0] - 2024-06-01 ### ๐Ÿš€ Features -- *(logging)* Determine the log level based on elaraDebug variable - ([93f8f8a](https://github.com/elaralang/elara/commit/93f8f8aefbe115ccd7bedaac3a404d15e3ececce)) -- *(pretty-printing)* Improve colourisation of pretty-printer output - ([28492c5](https://github.com/elaralang/elara/commit/28492c57370c98ea8142574261dc36d1b80185b9)) -- *(pretty-printing)* Remove the domain when printing foralls (as it will only ever be type) - ([2b5158e](https://github.com/elaralang/elara/commit/2b5158e3eb9459fb67079669025794a7fa81910a)) -- *(stdlib)* Restore the stdlib to its former glo - ([0fc83e9](https://github.com/elaralang/elara/commit/0fc83e918b2ecf1422cf08c226d7f49442f175b7)) -- *(stdlib)* Add primitive functions for working with strings - ([a582f06](https://github.com/elaralang/elara/commit/a582f0619b44bd20fc8fbbcfef4c744eb06a58fb)) -- *(type-infer)* Add a new error message in the case of multiple tyapps being detected (which shouldn't happen?) - ([7486ea1](https://github.com/elaralang/elara/commit/7486ea12c758a85334ff48556be6365bc63302fa)) +- *(logging)* Determine the log level based on elaraDebug variable - ([93f8f8a](https://github.com/ElaraLang/elara/commit/93f8f8aefbe115ccd7bedaac3a404d15e3ececce)) +- *(pretty-printing)* Improve colourisation of pretty-printer output - ([28492c5](https://github.com/ElaraLang/elara/commit/28492c57370c98ea8142574261dc36d1b80185b9)) +- *(pretty-printing)* Remove the domain when printing foralls (as it will only ever be type) - ([2b5158e](https://github.com/ElaraLang/elara/commit/2b5158e3eb9459fb67079669025794a7fa81910a)) +- *(stdlib)* Restore the stdlib to its former glo - ([0fc83e9](https://github.com/ElaraLang/elara/commit/0fc83e918b2ecf1422cf08c226d7f49442f175b7)) +- *(stdlib)* Add primitive functions for working with strings - ([a582f06](https://github.com/ElaraLang/elara/commit/a582f0619b44bd20fc8fbbcfef4c744eb06a58fb)) +- *(type-infer)* Add a new error message in the case of multiple tyapps being detected (which shouldn't happen?) - ([7486ea1](https://github.com/ElaraLang/elara/commit/7486ea12c758a85334ff48556be6365bc63302fa)) ### ๐Ÿ› Bug Fixes -- *(codegen)* Fix stringLength primitive not boxing integers - ([85fcf5a](https://github.com/elaralang/elara/commit/85fcf5a6e72d2cd27f68c0854de3bf54e7b54b80)) -- *(logging)* Remove old debugPretty calls - ([64edc03](https://github.com/elaralang/elara/commit/64edc0310f539740bc81138b6b042b9333501617)) -- *(tests)* Fix unit tests not compiling for various reasons - ([e0a2955](https://github.com/elaralang/elara/commit/e0a2955d618e7a6ea1d244d2cf4672fb476c51ed)) -- *(type-infer)* Fix constructor pattern arguments being reversed in type inference - ([321fdd6](https://github.com/elaralang/elara/commit/321fdd6fbe6aaad25a547006d753a97f616e18d9)) -- *(type-infer)* Fix conversion between types when explicitly applying type constructors (eg `def x : Option Int`) - ([940e960](https://github.com/elaralang/elara/commit/940e9608a699d06b9324f169cc1367afc43907d9)) -- *(type-infer)* Fix constructor patterns not being completely solved - ([1dc7624](https://github.com/elaralang/elara/commit/1dc7624f1dbaeab084a4fb7e3ae23170eb92337a)) -- *(type-infer)* Fix type inference logging _always_ being on debug - ([3b34bb1](https://github.com/elaralang/elara/commit/3b34bb1e216fafad98cf08c1d0dec4f242b61587)) -- *(type-infer)* Fix if/else type inference not always unifying correctly and throwing errors - ([33a72c2](https://github.com/elaralang/elara/commit/33a72c2103a1657dc9626176c2eb683513e9d4bf)) -- *(type-infer)* Improve algorithm for detecting tyapps, fixing some edge cases - ([8503c23](https://github.com/elaralang/elara/commit/8503c23109a8f79180a70b77393040141d6527df)) +- *(codegen)* Fix stringLength primitive not boxing integers - ([85fcf5a](https://github.com/ElaraLang/elara/commit/85fcf5a6e72d2cd27f68c0854de3bf54e7b54b80)) +- *(logging)* Remove old debugPretty calls - ([64edc03](https://github.com/ElaraLang/elara/commit/64edc0310f539740bc81138b6b042b9333501617)) +- *(tests)* Fix unit tests not compiling for various reasons - ([e0a2955](https://github.com/ElaraLang/elara/commit/e0a2955d618e7a6ea1d244d2cf4672fb476c51ed)) +- *(type-infer)* Fix constructor pattern arguments being reversed in type inference - ([321fdd6](https://github.com/ElaraLang/elara/commit/321fdd6fbe6aaad25a547006d753a97f616e18d9)) +- *(type-infer)* Fix conversion between types when explicitly applying type constructors (eg `def x : Option Int`) - ([940e960](https://github.com/ElaraLang/elara/commit/940e9608a699d06b9324f169cc1367afc43907d9)) +- *(type-infer)* Fix constructor patterns not being completely solved - ([1dc7624](https://github.com/ElaraLang/elara/commit/1dc7624f1dbaeab084a4fb7e3ae23170eb92337a)) +- *(type-infer)* Fix type inference logging _always_ being on debug - ([3b34bb1](https://github.com/ElaraLang/elara/commit/3b34bb1e216fafad98cf08c1d0dec4f242b61587)) +- *(type-infer)* Fix if/else type inference not always unifying correctly and throwing errors - ([33a72c2](https://github.com/ElaraLang/elara/commit/33a72c2103a1657dc9626176c2eb683513e9d4bf)) +- *(type-infer)* Improve algorithm for detecting tyapps, fixing some edge cases - ([8503c23](https://github.com/ElaraLang/elara/commit/8503c23109a8f79180a70b77393040141d6527df)) - Fix the tests - - ([1273624](https://github.com/elaralang/elara/commit/1273624f5efd8a4dc9a52df073e199c03a180874)) + - ([1273624](https://github.com/ElaraLang/elara/commit/1273624f5efd8a4dc9a52df073e199c03a180874)) - Fix name shadowing in inspection - - ([56dc353](https://github.com/elaralang/elara/commit/56dc3534dfa22b5aee0582788784570c7560486e)) + - ([56dc353](https://github.com/ElaraLang/elara/commit/56dc3534dfa22b5aee0582788784570c7560486e)) - Fix haddock comment - - ([945cd39](https://github.com/elaralang/elara/commit/945cd398eaccb880d36017ba8f06279ba93880ae)) + - ([945cd39](https://github.com/ElaraLang/elara/commit/945cd398eaccb880d36017ba8f06279ba93880ae)) - Fix latex - - ([57cb4ac](https://github.com/elaralang/elara/commit/57cb4ac62336eea9cddb65e24c730b70d3533801)) + - ([57cb4ac](https://github.com/ElaraLang/elara/commit/57cb4ac62336eea9cddb65e24c730b70d3533801)) - Fix a bunch of warnings :D - - ([bef63d7](https://github.com/elaralang/elara/commit/bef63d70b55ed5e988bd822513df2ed95c44bdde)) + - ([bef63d7](https://github.com/ElaraLang/elara/commit/bef63d70b55ed5e988bd822513df2ed95c44bdde)) - Fix some more warnings - - ([ea6b295](https://github.com/elaralang/elara/commit/ea6b295a211c57609665f2c23833578738d485a2)) + - ([ea6b295](https://github.com/ElaraLang/elara/commit/ea6b295a211c57609665f2c23833578738d485a2)) - Fix more warnings - - ([877fa2d](https://github.com/elaralang/elara/commit/877fa2df71692775c9cba46f92c361fae38b747b)) + - ([877fa2d](https://github.com/ElaraLang/elara/commit/877fa2df71692775c9cba46f92c361fae38b747b)) - Fix a naughty parser edge case, but now indentation is broken - - ([fb64659](https://github.com/elaralang/elara/commit/fb646599f65db122aa30e5cea8a250e055de5429)) + - ([fb64659](https://github.com/ElaraLang/elara/commit/fb646599f65db122aa30e5cea8a250e055de5429)) - Fix local let bindings not being annotated properly - - ([5437b1b](https://github.com/elaralang/elara/commit/5437b1bc0f789b89090689919a0cda3e3f873684)) + - ([5437b1b](https://github.com/ElaraLang/elara/commit/5437b1bc0f789b89090689919a0cda3e3f873684)) - Fix parsing tests, make let-binding names unqualified - - ([16221a2](https://github.com/elaralang/elara/commit/16221a2b96fd9ddf7dc6e80b1523c8ae08376253)) + - ([16221a2](https://github.com/ElaraLang/elara/commit/16221a2b96fd9ddf7dc6e80b1523c8ae08376253)) - Fix funny quickcheck edge cases - - ([c231e2a](https://github.com/elaralang/elara/commit/c231e2ac6872efe1d4aac5590087f6f01c0ea446)) + - ([c231e2a](https://github.com/ElaraLang/elara/commit/c231e2ac6872efe1d4aac5590087f6f01c0ea446)) - Fix some haddock typos - - ([543a982](https://github.com/elaralang/elara/commit/543a982fb6c6c2bb9e288465ace248b64eb73ba0)) + - ([543a982](https://github.com/ElaraLang/elara/commit/543a982fb6c6c2bb9e288465ace248b64eb73ba0)) - Fix let-in error - - ([9b60ec8](https://github.com/elaralang/elara/commit/9b60ec83ea45e08cfd022832c64c890a0f748a88)) + - ([9b60ec8](https://github.com/ElaraLang/elara/commit/9b60ec83ea45e08cfd022832c64c890a0f748a88)) - Fix prettyprint infinite loop lol - - ([ace5c19](https://github.com/elaralang/elara/commit/ace5c19e65adf51e119efa3af67a99eaa8addc66)) + - ([ace5c19](https://github.com/ElaraLang/elara/commit/ace5c19e65adf51e119efa3af67a99eaa8addc66)) - Fix unification with type declarations - - ([24e2278](https://github.com/elaralang/elara/commit/24e2278773432462e072d1e412e530ac30d52026)) + - ([24e2278](https://github.com/ElaraLang/elara/commit/24e2278773432462e072d1e412e530ac30d52026)) - Fix da nix - - ([7ed19ef](https://github.com/elaralang/elara/commit/7ed19ef155b2f56e03544e06de7bdef3ac6aeee4)) + - ([7ed19ef](https://github.com/ElaraLang/elara/commit/7ed19ef155b2f56e03544e06de7bdef3ac6aeee4)) - Fix da stack (doesnt rhyme sorry) - - ([79018aa](https://github.com/elaralang/elara/commit/79018aabb9594ee3aef344f8b92c03fbba2b1583)) + - ([79018aa](https://github.com/ElaraLang/elara/commit/79018aabb9594ee3aef344f8b92c03fbba2b1583)) - Fix type inference? - - ([b05c98a](https://github.com/elaralang/elara/commit/b05c98a9ff0afeabb47155c88ab6c1643253c3fd)) + - ([b05c98a](https://github.com/ElaraLang/elara/commit/b05c98a9ff0afeabb47155c88ab6c1643253c3fd)) - Fix hie - - ([2b53f88](https://github.com/elaralang/elara/commit/2b53f88ee07827d67cf0c7ccce5520ffeb38b7bc)) + - ([2b53f88](https://github.com/ElaraLang/elara/commit/2b53f88ee07827d67cf0c7ccce5520ffeb38b7bc)) - Fix unit tests - - ([2ef17dd](https://github.com/elaralang/elara/commit/2ef17dd60ebfabbec9f05a7b67fcfb2528e02db2)) + - ([2ef17dd](https://github.com/ElaraLang/elara/commit/2ef17dd60ebfabbec9f05a7b67fcfb2528e02db2)) - Fix doctests - - ([f2543c7](https://github.com/elaralang/elara/commit/f2543c7bd40427ad91488df1dc959d6df58c8774)) + - ([f2543c7](https://github.com/ElaraLang/elara/commit/f2543c7bd40427ad91488df1dc959d6df58c8774)) - Fix the pattern parser & add a lot of tests - - ([94d1669](https://github.com/elaralang/elara/commit/94d1669fa7c151d4d36964fa3a05ca185173cb1b)) + - ([94d1669](https://github.com/ElaraLang/elara/commit/94d1669fa7c151d4d36964fa3a05ca185173cb1b)) - Fix lots of bugs! - - ([438e69f](https://github.com/elaralang/elara/commit/438e69f744c68b730aa625e891e593d57a5aaff7)) + - ([438e69f](https://github.com/ElaraLang/elara/commit/438e69f744c68b730aa625e891e593d57a5aaff7)) - Fix subtyping on custom types - - ([c790d2f](https://github.com/elaralang/elara/commit/c790d2f756aef3386a5f54ff8fd32898f11dbd27)) + - ([c790d2f](https://github.com/ElaraLang/elara/commit/c790d2f756aef3386a5f54ff8fd32898f11dbd27)) - Fix stupid ugly CI (maybe) - - ([ad7a872](https://github.com/elaralang/elara/commit/ad7a87227ce7a506a5903c228ea390f17fb517e7)) + - ([ad7a872](https://github.com/ElaraLang/elara/commit/ad7a87227ce7a506a5903c228ea390f17fb517e7)) - Fix some warnings and refactor even more - - ([1d96b4d](https://github.com/elaralang/elara/commit/1d96b4d7d96379084a914f3d8090bf4de9078be1)) + - ([1d96b4d](https://github.com/ElaraLang/elara/commit/1d96b4d7d96379084a914f3d8090bf4de9078be1)) - Fix a morbillion more warnings - - ([be1c891](https://github.com/elaralang/elara/commit/be1c891aadf9850bb817aa0aaca5216b1ba6568b)) + - ([be1c891](https://github.com/ElaraLang/elara/commit/be1c891aadf9850bb817aa0aaca5216b1ba6568b)) - Fix almost all the warnings - - ([351f7fb](https://github.com/elaralang/elara/commit/351f7fb55ed24254401eb88894cc790719a3069d)) + - ([351f7fb](https://github.com/ElaraLang/elara/commit/351f7fb55ed24254401eb88894cc790719a3069d)) - Fix a very rare lexer edge case - - ([b0369fc](https://github.com/elaralang/elara/commit/b0369fcc435934d20876ae0dd08e0c165acc8e11)) + - ([b0369fc](https://github.com/ElaraLang/elara/commit/b0369fcc435934d20876ae0dd08e0c165acc8e11)) - Fix build error - - ([c154b25](https://github.com/elaralang/elara/commit/c154b25657399e75d675761e97f0baf597714dbb)) + - ([c154b25](https://github.com/ElaraLang/elara/commit/c154b25657399e75d675761e97f0baf597714dbb)) - Fix the tests not compiling (oops) - - ([4a620ee](https://github.com/elaralang/elara/commit/4a620ee9f3549ce4592ca06a88cfe8f57b9497a4)) + - ([4a620ee](https://github.com/ElaraLang/elara/commit/4a620ee9f3549ce4592ca06a88cfe8f57b9497a4)) - Fix the tests not compiling (oops) - - ([4ff8661](https://github.com/elaralang/elara/commit/4ff8661e822452390a0ebc402a7055c152a638f8)) + - ([4ff8661](https://github.com/ElaraLang/elara/commit/4ff8661e822452390a0ebc402a7055c152a638f8)) - Fix let-in constructs being given the wrong type in core - - ([e52396e](https://github.com/elaralang/elara/commit/e52396e44274be57da41a52fe7189040cbd40a57)) + - ([e52396e](https://github.com/ElaraLang/elara/commit/e52396e44274be57da41a52fe7189040cbd40a57)) - Fix maxLocals for - - ([1a09f30](https://github.com/elaralang/elara/commit/1a09f30c220e563ca60d2d610e7b7ab65838a580)) + - ([1a09f30](https://github.com/ElaraLang/elara/commit/1a09f30c220e563ca60d2d610e7b7ab65838a580)) - Fix bug in renaming let statements - - ([4825d10](https://github.com/elaralang/elara/commit/4825d102860a0a61c8dae696875b42cff7eb6c44)) + - ([4825d10](https://github.com/ElaraLang/elara/commit/4825d102860a0a61c8dae696875b42cff7eb6c44)) - Fix the cons type - - ([8813151](https://github.com/elaralang/elara/commit/8813151a17505b3224514a429c93df1220e03302)) + - ([8813151](https://github.com/ElaraLang/elara/commit/8813151a17505b3224514a429c93df1220e03302)) - Fix parse error with higher order functions - - ([4452451](https://github.com/elaralang/elara/commit/44524515c89c7a84dd3578228fee0c609a539b04)) + - ([4452451](https://github.com/ElaraLang/elara/commit/44524515c89c7a84dd3578228fee0c609a539b04)) - Fix unnecessary type applications being added - - ([09dc4ba](https://github.com/elaralang/elara/commit/09dc4ba5e96d93dc09cebe79a170815b0c479d4a)) + - ([09dc4ba](https://github.com/ElaraLang/elara/commit/09dc4ba5e96d93dc09cebe79a170815b0c479d4a)) - Fix variables in ToCore using the wrong types - - ([d3da4bb](https://github.com/elaralang/elara/commit/d3da4bb60b3ee3e376b19939fa067a85819aae95)) + - ([d3da4bb](https://github.com/ElaraLang/elara/commit/d3da4bb60b3ee3e376b19939fa067a85819aae95)) - Fix (?) type inference for list literals - - ([8a20d85](https://github.com/elaralang/elara/commit/8a20d856748c3472b488fa719b3c117074a5b07f)) + - ([8a20d85](https://github.com/ElaraLang/elara/commit/8a20d856748c3472b488fa719b3c117074a5b07f)) - Fix CI - - ([34bbcb0](https://github.com/elaralang/elara/commit/34bbcb0fe09c74121a723c2da76c6aff86e3887c)) + - ([34bbcb0](https://github.com/ElaraLang/elara/commit/34bbcb0fe09c74121a723c2da76c6aff86e3887c)) - Fix undefined handling - - ([85a0df4](https://github.com/elaralang/elara/commit/85a0df48b54f9cb6e76ff487150f840d0a4d1cdc)) + - ([85a0df4](https://github.com/ElaraLang/elara/commit/85a0df48b54f9cb6e76ff487150f840d0a4d1cdc)) - Fix |> and emitting higher order functions - - ([69b3236](https://github.com/elaralang/elara/commit/69b3236708023b15ea9aed0b011d324bf7990ae5)) + - ([69b3236](https://github.com/ElaraLang/elara/commit/69b3236708023b15ea9aed0b011d324bf7990ae5)) - Fix more tyapps - - ([70aae06](https://github.com/elaralang/elara/commit/70aae06edb2a4ea2ebdcc31707532b1a68624ff3)) + - ([70aae06](https://github.com/ElaraLang/elara/commit/70aae06edb2a4ea2ebdcc31707532b1a68624ff3)) - Fix redundant pattern match warning with Local' & Global' - - ([cd0ca0c](https://github.com/elaralang/elara/commit/cd0ca0c8b7982a9083c20ea2adfbfed25ad1a331)) + - ([cd0ca0c](https://github.com/ElaraLang/elara/commit/cd0ca0c8b7982a9083c20ea2adfbfed25ad1a331)) - Fix core type instantiation being incorrect - - ([97427ab](https://github.com/elaralang/elara/commit/97427ab1a7731e19bb4ccec1170c5f4350158e0a)) + - ([97427ab](https://github.com/ElaraLang/elara/commit/97427ab1a7731e19bb4ccec1170c5f4350158e0a)) - Fix match expressions inferring to the wrong type - - ([ad97cef](https://github.com/elaralang/elara/commit/ad97cefc9f91e5385977692e78b78b83974825d1)) + - ([ad97cef](https://github.com/ElaraLang/elara/commit/ad97cefc9f91e5385977692e78b78b83974825d1)) - Fix ci running - - ([a858457](https://github.com/elaralang/elara/commit/a8584571399ee3ff27f7fcae80546b012a5945eb)) + - ([a858457](https://github.com/ElaraLang/elara/commit/a8584571399ee3ff27f7fcae80546b012a5945eb)) - Fix shunt tests - - ([d017534](https://github.com/elaralang/elara/commit/d017534f7c17767811bd2663d4167d2b8a30b782)) + - ([d017534](https://github.com/ElaraLang/elara/commit/d017534f7c17767811bd2663d4167d2b8a30b782)) - Fix a bunch of warnings - - ([aa811c7](https://github.com/elaralang/elara/commit/aa811c7ccc41b085aa58a78cdeb59bfbf57762fe)) + - ([aa811c7](https://github.com/ElaraLang/elara/commit/aa811c7ccc41b085aa58a78cdeb59bfbf57762fe)) - Fix the unit tests compiling - - ([b2e838d](https://github.com/elaralang/elara/commit/b2e838dc9ee35e6a9f8abb7a9a01064904d1c682)) + - ([b2e838d](https://github.com/ElaraLang/elara/commit/b2e838dc9ee35e6a9f8abb7a9a01064904d1c682)) - Fix all tests - - ([216af73](https://github.com/elaralang/elara/commit/216af73edfeb5da214999f961bcbc52bdc73591b)) + - ([216af73](https://github.com/ElaraLang/elara/commit/216af73edfeb5da214999f961bcbc52bdc73591b)) - Fix gh workflow - - ([143afe5](https://github.com/elaralang/elara/commit/143afe5adb1f55a401bcdd4cda9a545d12e5828f)) + - ([143afe5](https://github.com/ElaraLang/elara/commit/143afe5adb1f55a401bcdd4cda9a545d12e5828f)) - Fix order of lambda params - - ([34b992c](https://github.com/elaralang/elara/commit/34b992c8b58d478dbacf68e54398ecbaa7d384eb)) + - ([34b992c](https://github.com/ElaraLang/elara/commit/34b992c8b58d478dbacf68e54398ecbaa7d384eb)) - Fix weird deveshell bug - - ([018ad04](https://github.com/elaralang/elara/commit/018ad047f2573e477a51b63b0058a554ef5fcc7a)) + - ([018ad04](https://github.com/ElaraLang/elara/commit/018ad047f2573e477a51b63b0058a554ef5fcc7a)) - Fix Show instance for UniqueID - - ([69abce6](https://github.com/elaralang/elara/commit/69abce637f21705340360d45bb5b247826c50aa9)) + - ([69abce6](https://github.com/ElaraLang/elara/commit/69abce637f21705340360d45bb5b247826c50aa9)) - Fix a bunch of warnings - - ([ca5bada](https://github.com/elaralang/elara/commit/ca5badadb5429e8eea76dee44db34eb2aa4bbef0)) + - ([ca5bada](https://github.com/ElaraLang/elara/commit/ca5badadb5429e8eea76dee44db34eb2aa4bbef0)) - Fix tests too - - ([8ac8089](https://github.com/elaralang/elara/commit/8ac8089176bc12bea0878ab39e202a6a2252c289)) + - ([8ac8089](https://github.com/ElaraLang/elara/commit/8ac8089176bc12bea0878ab39e202a6a2252c289)) - Fix unix build - - ([02d1936](https://github.com/elaralang/elara/commit/02d1936da432f7fe6c75bfe28c9898fab7e25509)) + - ([02d1936](https://github.com/ElaraLang/elara/commit/02d1936da432f7fe6c75bfe28c9898fab7e25509)) - Fix crlf endings breaking lexer - - ([5c23b0c](https://github.com/elaralang/elara/commit/5c23b0cc250289fcd99b224df6f54fd34fd559a1)) + - ([5c23b0c](https://github.com/ElaraLang/elara/commit/5c23b0cc250289fcd99b224df6f54fd34fd559a1)) - Fix unit tests - - ([164dc28](https://github.com/elaralang/elara/commit/164dc284d4d83ecb063bd8208f036811f3f5fed9)) + - ([164dc28](https://github.com/ElaraLang/elara/commit/164dc284d4d83ecb063bd8208f036811f3f5fed9)) - Fix jvm separator on windows - - ([59674d7](https://github.com/elaralang/elara/commit/59674d7c3bf625dc84c8176d43aa0034b198cbb7)) + - ([59674d7](https://github.com/ElaraLang/elara/commit/59674d7c3bf625dc84c8176d43aa0034b198cbb7)) - Fix parsing of constructor patterns with args without parens - - ([aadac49](https://github.com/elaralang/elara/commit/aadac49e00acf5d3e60b13bef214be081f38b919)) + - ([aadac49](https://github.com/ElaraLang/elara/commit/aadac49e00acf5d3e60b13bef214be081f38b919)) - Fix graph topology due from constructor patterns - - ([5184f39](https://github.com/elaralang/elara/commit/5184f393679f5b66a4f3ac5357a5439382f3cfe8)) + - ([5184f39](https://github.com/ElaraLang/elara/commit/5184f393679f5b66a4f3ac5357a5439382f3cfe8)) - Fix constructors with multiple fields being invalidly generated - - ([6fd72ae](https://github.com/elaralang/elara/commit/6fd72ae0a78a4aabf87112f7e81741669f7b6a05)) + - ([6fd72ae](https://github.com/ElaraLang/elara/commit/6fd72ae0a78a4aabf87112f7e81741669f7b6a05)) - Fix wrong toString append being used - - ([a668e0a](https://github.com/elaralang/elara/commit/a668e0a3530bc5a264e16a15a42ee58e6dabb4f0)) + - ([a668e0a](https://github.com/ElaraLang/elara/commit/a668e0a3530bc5a264e16a15a42ee58e6dabb4f0)) - Fix adt match calling in the wrong order - - ([a396b22](https://github.com/elaralang/elara/commit/a396b224f317bd16b17ce88e849f5c1a4a2ce0ce)) + - ([a396b22](https://github.com/ElaraLang/elara/commit/a396b224f317bd16b17ce88e849f5c1a4a2ce0ce)) - Fix type / kind inference and such - - ([49fcb62](https://github.com/elaralang/elara/commit/49fcb624a679122d726b5c7b08685b86f6d4a127)) + - ([49fcb62](https://github.com/ElaraLang/elara/commit/49fcb624a679122d726b5c7b08685b86f6d4a127)) - Fix the prettyprinter changes breaking the unit tests - - ([207856e](https://github.com/elaralang/elara/commit/207856e27346683d85001b2ad8cbb49c66d6b618)) -- Fix code generation for constructor patterns with multiple arguments breaking - ([6de3e20](https://github.com/elaralang/elara/commit/6de3e203a2d6ac90b98e7aea835062189a717621)) + - ([207856e](https://github.com/ElaraLang/elara/commit/207856e27346683d85001b2ad8cbb49c66d6b618)) +- Fix code generation for constructor patterns with multiple arguments breaking - ([6de3e20](https://github.com/ElaraLang/elara/commit/6de3e203a2d6ac90b98e7aea835062189a717621)) ### ๐Ÿšœ Refactor -- *(stdlib)* Move ALL mentions of lists to the stdlib - they are no longer a primitive! - ([8e3d367](https://github.com/elaralang/elara/commit/8e3d367d94078552ea642851654c7abe7b7ff42e)) -- *(stdlib)* Refactor Elara Stdlib and add list length function - ([2fa03be](https://github.com/elaralang/elara/commit/2fa03be4f9acc294bc2d0a41f5314fb9aceba625)) -- *(stdlib)* [**breaking**] Change `readFile` to return String rather than EList - ([01f4048](https://github.com/elaralang/elara/commit/01f40486c687c47d8f17a7795931d65c4f606e11)) +- *(stdlib)* Move ALL mentions of lists to the stdlib - they are no longer a primitive! - ([8e3d367](https://github.com/ElaraLang/elara/commit/8e3d367d94078552ea642851654c7abe7b7ff42e)) +- *(stdlib)* Refactor Elara Stdlib and add list length function - ([2fa03be](https://github.com/ElaraLang/elara/commit/2fa03be4f9acc294bc2d0a41f5314fb9aceba625)) +- *(stdlib)* [**breaking**] Change `readFile` to return String rather than EList - ([01f4048](https://github.com/ElaraLang/elara/commit/01f40486c687c47d8f17a7795931d65c4f606e11)) - Refactor tests - - ([8151cfd](https://github.com/elaralang/elara/commit/8151cfde6fec3c8cc106c20ce0ffc7885a507f63)) + - ([8151cfd](https://github.com/ElaraLang/elara/commit/8151cfde6fec3c8cc106c20ce0ffc7885a507f63)) - Refactors - - ([718aa8a](https://github.com/elaralang/elara/commit/718aa8aa8e3f4a33ede2375f3854c7a33e6948cc)) + - ([718aa8a](https://github.com/ElaraLang/elara/commit/718aa8aa8e3f4a33ede2375f3854c7a33e6948cc)) - Refactor HasDependencies to allow multiple keys - - ([5d1490e](https://github.com/elaralang/elara/commit/5d1490e75e41ad492164850c909a7c96fb2c9619)) + - ([5d1490e](https://github.com/ElaraLang/elara/commit/5d1490e75e41ad492164850c909a7c96fb2c9619)) - Refactor how type constructors are handled in core - - ([ba962be](https://github.com/elaralang/elara/commit/ba962be52873f8093166170256650c681b48c715)) -- Slightly tidy up generation of lambdas - ([4654676](https://github.com/elaralang/elara/commit/4654676b73c2fa3258d9b3bf044f56e7a2f6e677)) -- Begin work refactoring lambda generation - keep track of parameter names _eerywhere_ - ([9f8ed70](https://github.com/elaralang/elara/commit/9f8ed708d95cab1b5106606d15e96aa9d3aecd91)) + - ([ba962be](https://github.com/ElaraLang/elara/commit/ba962be52873f8093166170256650c681b48c715)) +- Slightly tidy up generation of lambdas - ([4654676](https://github.com/ElaraLang/elara/commit/4654676b73c2fa3258d9b3bf044f56e7a2f6e677)) +- Begin work refactoring lambda generation - keep track of parameter names _eerywhere_ - ([9f8ed70](https://github.com/ElaraLang/elara/commit/9f8ed708d95cab1b5106606d15e96aa9d3aecd91)) ### ๐Ÿ“š Documentation -- *(stdlib)* Remove mention of EList from readme compiling guide - ([624a156](https://github.com/elaralang/elara/commit/624a156569ef71567788a0d380ea13212dd5d9c5)) +- *(stdlib)* Remove mention of EList from readme compiling guide - ([624a156](https://github.com/ElaraLang/elara/commit/624a156569ef71567788a0d380ea13212dd5d9c5)) - Document the pipeline a bit - - ([efd41ea](https://github.com/elaralang/elara/commit/efd41ea37b869d5249de26cf3eee44fb6176915c)) + - ([efd41ea](https://github.com/ElaraLang/elara/commit/efd41ea37b869d5249de26cf3eee44fb6176915c)) ### ๐ŸŽจ Styling -- *(actions)* Remove blank line - ([9b61673](https://github.com/elaralang/elara/commit/9b6167309e788bcaa4adc40493db610ef88a70c3)) -- *(tocore)* Change weird usage of =<< in ToCore - ([936ab2a](https://github.com/elaralang/elara/commit/936ab2a3ec0b740fabae2c0954cc29d1f4cb4b24)) +- *(actions)* Remove blank line - ([9b61673](https://github.com/ElaraLang/elara/commit/9b6167309e788bcaa4adc40493db610ef88a70c3)) +- *(tocore)* Change weird usage of =<< in ToCore - ([936ab2a](https://github.com/ElaraLang/elara/commit/936ab2a3ec0b740fabae2c0954cc29d1f4cb4b24)) ### ๐Ÿงช Testing -- *(type-infer)* Add new tests for type application insertion - ([a341c65](https://github.com/elaralang/elara/commit/a341c6597677d6ff814d73cd6896231e7ed3f8b4)) -- *(type-infer)* Uncomment test for `forall a. a` tyapps - ([e2786a0](https://github.com/elaralang/elara/commit/e2786a056b7ab8ba46b96616cc953f6da3e84736)) -- Test - ([dd1a893](https://github.com/elaralang/elara/commit/dd1a8930c50658d46009a6690db05244acd81532)) +- *(type-infer)* Add new tests for type application insertion - ([a341c65](https://github.com/ElaraLang/elara/commit/a341c6597677d6ff814d73cd6896231e7ed3f8b4)) +- *(type-infer)* Uncomment test for `forall a. a` tyapps - ([e2786a0](https://github.com/ElaraLang/elara/commit/e2786a056b7ab8ba46b96616cc953f6da3e84736)) +- Test - ([dd1a893](https://github.com/ElaraLang/elara/commit/dd1a8930c50658d46009a6690db05244acd81532)) ### โš™๏ธ Miscellaneous Tasks -- *(actions)* Try deleting this folder - ([fb8c8bd](https://github.com/elaralang/elara/commit/fb8c8bd56ee9b231b39e1004123883934913c0a6)) -- *(actions)* Change the script...? - ([27dc8ea](https://github.com/elaralang/elara/commit/27dc8eaac5a23a955ae7336e96320b95663906d2)) -- *(actions)* Run linux builds on self-hosted runner - ([e47fa1a](https://github.com/elaralang/elara/commit/e47fa1acbdc2e180788bd8c008331baaa665392a)) -- *(actions)* Nevermind let's not do that - ([c684cb9](https://github.com/elaralang/elara/commit/c684cb95ab3c53c4a2508ccc8a8b676b5c6f7cc7)) -- *(actions)* Log big files - ([e0158fd](https://github.com/elaralang/elara/commit/e0158fd46eb94fcaaf9df45b06dd4ceb8526e4fc)) -- *(actions)* That seemed to work - now remove the logging - ([f9a9294](https://github.com/elaralang/elara/commit/f9a9294cc28589d3204c5c1e3c4e84f0a95764cf)) -- *(logging)* Change back to info logging (really need to make this configurable at runtime) - ([7666ae9](https://github.com/elaralang/elara/commit/7666ae96126238a5f453a4462aedb692d0316093)) -- *(nix)* Move from mission-control to just - ([ba41767](https://github.com/elaralang/elara/commit/ba4176752274ae6b6cdbc870d8bc1d808378380d)) -- *(nix)* Add the old mission-control scripts back to the justfile - ([1508631](https://github.com/elaralang/elara/commit/15086319ecb703d2774a436775312f7409df0489)) -- *(stdlib)* Remove random list from main file - ([85524a1](https://github.com/elaralang/elara/commit/85524a108d84963b0b7090093ffb952e9d4ff4f8)) +- *(actions)* Try deleting this folder - ([fb8c8bd](https://github.com/ElaraLang/elara/commit/fb8c8bd56ee9b231b39e1004123883934913c0a6)) +- *(actions)* Change the script...? - ([27dc8ea](https://github.com/ElaraLang/elara/commit/27dc8eaac5a23a955ae7336e96320b95663906d2)) +- *(actions)* Run linux builds on self-hosted runner - ([e47fa1a](https://github.com/ElaraLang/elara/commit/e47fa1acbdc2e180788bd8c008331baaa665392a)) +- *(actions)* Nevermind let's not do that - ([c684cb9](https://github.com/ElaraLang/elara/commit/c684cb95ab3c53c4a2508ccc8a8b676b5c6f7cc7)) +- *(actions)* Log big files - ([e0158fd](https://github.com/ElaraLang/elara/commit/e0158fd46eb94fcaaf9df45b06dd4ceb8526e4fc)) +- *(actions)* That seemed to work - now remove the logging - ([f9a9294](https://github.com/ElaraLang/elara/commit/f9a9294cc28589d3204c5c1e3c4e84f0a95764cf)) +- *(logging)* Change back to info logging (really need to make this configurable at runtime) - ([7666ae9](https://github.com/ElaraLang/elara/commit/7666ae96126238a5f453a4462aedb692d0316093)) +- *(nix)* Move from mission-control to just - ([ba41767](https://github.com/ElaraLang/elara/commit/ba4176752274ae6b6cdbc870d8bc1d808378380d)) +- *(nix)* Add the old mission-control scripts back to the justfile - ([1508631](https://github.com/ElaraLang/elara/commit/15086319ecb703d2774a436775312f7409df0489)) +- *(stdlib)* Remove random list from main file - ([85524a1](https://github.com/ElaraLang/elara/commit/85524a108d84963b0b7090093ffb952e9d4ff4f8)) ### Build -- *(nix)* Update nix flake - ([f95de02](https://github.com/elaralang/elara/commit/f95de028cc2349f71901f8c5c7e7b0cd8e4b1558)) +- *(nix)* Update nix flake - ([f95de02](https://github.com/ElaraLang/elara/commit/f95de028cc2349f71901f8c5c7e7b0cd8e4b1558)) From d22a9b59bdc87a5bbb11a350b95d275d5eae6ab2 Mon Sep 17 00:00:00 2001 From: Alexander Wood Date: Sat, 1 Jun 2024 22:26:54 +0100 Subject: [PATCH 06/12] feat(renamer): :bug: Fix #14 and significantly improve error message quality for unknown names Fixes issues where names are implicitly imported because other modules imported them. Additionally, significantly improves the quality of error messages related to unknown names, now suggesting typo fixes or imports to add --- app/Main.hs | 3 +- elara.cabal | 3 + package.yaml | 1 + source.elr | 4 +- src/Elara/Rename.hs | 178 +++++++++++++++++++++++++++++++++----------- stdlib/prelude.elr | 1 + 6 files changed, 141 insertions(+), 49 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index fd753ac..5526455 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -193,8 +193,7 @@ processModules graph (dumpShunted, dumpTyped) = >=> traverseGraphRevTopologically inferModule >=> dumpIf fst dumpTyped (view (_Unwrapped % unlocated % field' @"name" % to nameText)) ".typed.elr" >=> traverseGraphRevTopologically (\(a, b) -> moduleToCore b a) - >=> pure - . mapGraph coreToCore + >=> (pure . mapGraph coreToCore) $ graph ) where diff --git a/elara.cabal b/elara.cabal index dea22c7..43b370a 100644 --- a/elara.cabal +++ b/elara.cabal @@ -175,6 +175,7 @@ library , safe-exceptions , stringsearch , terminal-size + , text-metrics , utf8-string mixins: base hiding (Prelude) @@ -231,6 +232,7 @@ executable elara , safe-exceptions , stringsearch , terminal-size + , text-metrics , utf8-string mixins: base hiding (Prelude) @@ -312,6 +314,7 @@ test-suite elara-test , safe-exceptions , stringsearch , terminal-size + , text-metrics , utf8-string mixins: base hiding (Prelude) diff --git a/package.yaml b/package.yaml index 8fa8da8..7975bc3 100644 --- a/package.yaml +++ b/package.yaml @@ -46,6 +46,7 @@ dependencies: - hashable - process - stringsearch + - text-metrics ghc-options: - -Wall diff --git a/source.elr b/source.elr index d12ca06..882a9d0 100644 --- a/source.elr +++ b/source.elr @@ -1,8 +1,8 @@ import Prelude import Option -import List +import Elara.Prim let inc x = x + 1 let main = - print (Option.map inc (Some 5)) + print (map incc (Some 5)) diff --git a/src/Elara/Rename.hs b/src/Elara/Rename.hs index 627e392..238e0b4 100644 --- a/src/Elara/Rename.hs +++ b/src/Elara/Rename.hs @@ -10,19 +10,21 @@ This stage handles: -} module Elara.Rename where -import Data.Generics.Product +import Data.Generics.Product hiding (list) +import Data.Generics.Sum (AsAny (_As)) import Data.Generics.Wrapped import Data.List.NonEmpty qualified as NonEmpty import Data.Map qualified as Map +import Data.Text.Metrics (levenshtein) import Elara.AST.Desugared -import Elara.AST.Generic +import Elara.AST.Generic hiding (moduleName) import Elara.AST.Generic.Common import Elara.AST.Module -import Elara.AST.Name (LowerAlphaName (..), MaybeQualified (MaybeQualified), ModuleName, Name (NTypeName, NVarName), Qualified (Qualified), ToName (toName), TypeName, VarName (NormalVarName, OperatorVarName), VarOrConName (..)) +import Elara.AST.Name (HasQualifier (qualifier), LowerAlphaName (..), MaybeQualified (MaybeQualified), ModuleName, Name (NTypeName, NVarName), NameLike (..), Qualified (Qualified), ToName (toName), TypeName, VarName (NormalVarName, OperatorVarName), VarOrConName (..)) import Elara.AST.Region (Located (Located), enclosingRegion', sourceRegion, sourceRegionToDiagnosePosition, spanningRegion', unlocated, withLocationOf) import Elara.AST.Renamed import Elara.AST.Select (LocatedAST (Desugared, Renamed)) -import Elara.AST.VarRef (VarRef, VarRef' (Global, Local)) +import Elara.AST.VarRef (VarRef, VarRef' (Global, Local), varRefVal) import Elara.Data.Pretty import Elara.Data.TopologicalGraph import Elara.Data.Unique (Unique, UniqueGen, makeUnique, uniqueGenToIO) @@ -32,26 +34,33 @@ import Elara.Pipeline import Elara.Prim.Core (consCtorName, emptyListCtorName) import Error.Diagnose (Marker (This, Where), Note (..), Report (Err)) import Optics (anyOf, filteredBy, traverseOf_) -import Polysemy (Member, Members, Sem) +import Polysemy (Member, Members, Sem, subsume) import Polysemy.Error (Error, note, throw) +import Polysemy.Log qualified as Log import Polysemy.Reader hiding (Local) import Polysemy.State import Polysemy.State.Extra import Polysemy.Utils (withModified) +import Print (showPretty) data RenameError = UnknownModule ModuleName | QualifiedInWrongModule ModuleName ModuleName | NonExistentModuleDeclaration ModuleName (Located Name) | UnknownTypeVariable LowerAlphaName - | UnknownName (Located Name) + | forall name. + ToName name => + UnknownName + -- | The name that was unknown + (Located Name) + -- | The module we're renaming that the unknown name was referenced in + (Module 'Desugared) + -- | All known names + (Map name (NonEmpty (VarRef name))) | AmbiguousVarName (Located Name) (NonEmpty (VarRef VarName)) | AmbiguousTypeName (Located Name) (NonEmpty (VarRef TypeName)) | NativeDefUnsupported (Located DesugaredDeclaration') | BlockEndsWithLet DesugaredExpr (Maybe DesugaredDeclarationBody) - deriving (Show) - -instance Exception RenameError instance ReportableError RenameError where report (UnknownModule mn) = @@ -83,17 +92,51 @@ instance ReportableError RenameError where ("Unknown type variable: " <> pretty n) [] [] - report (UnknownName n) = + report (UnknownName n m names) = do let nameKind = case n of Located _ (NVarName (NormalVarName _)) -> "variable" Located _ (NVarName (OperatorVarName _)) -> "operator" Located _ (NTypeName _) -> "type" - in writeReport $ - Err - Nothing - ("Unknown" <+> nameKind <+> "name: " <> pretty n) - [(n ^. sourceRegion % to sourceRegionToDiagnosePosition, This "referenced here")] - [] + -- search all names to suggest imports / similar names + let namesMap = Map.mapKeys toName names + let allNames = maybe [] toList (fmap toName <<$>> Map.lookup (n ^. unlocated) namesMap) + let namesThatMightveBeenIntendedButNotImported = + case filter (not . isImportedBy m) allNames of + [] -> [] + ns -> + [ Hint $ + vsep + [ "This name is defined in the following modules, but none of them are imported:" + , hsep (punctuate comma (ns ^.. each % _As @"Global" % unlocated % qualifier % to pretty)) + , "Try importing one of the modules." + ] + ] + let + prettyVarRef n@(Local{}) = pretty (toName $ view unlocated $ varRefVal n) <+> "(declared locally)" + prettyVarRef (Global (Located _ (Qualified n m))) = pretty (toName n) <+> "(imported from" <+> pretty m <> ")" + possibleTypos = + let intendedText = nameText n + isTypo name = levenshtein (nameText name) intendedText < 3 + typos = + Map.filterWithKey + (\k _ -> isTypo k) + (NonEmpty.filter (\x -> isImportedBy m (toName <$> x)) <$> namesMap) + in case join (Map.elems typos) of + [] -> [] + ts -> + [ Hint $ + vsep + [ "You may have meant one of:" + , listToText (prettyVarRef <$> ts) + ] + ] + + writeReport $ + Err + Nothing + ("Unknown" <+> nameKind <+> "name: " <> pretty n) + [(n ^. sourceRegion % to sourceRegionToDiagnosePosition, This "referenced here")] + (namesThatMightveBeenIntendedButNotImported <> possibleTypos) report (NativeDefUnsupported _) = writeReport $ Err @@ -167,9 +210,14 @@ type RenamePipelineEffects = , Error RenameError , Reader (TopologicalGraph (Module 'Desugared)) , UniqueGen + , Log.Log ] type Rename r = Members RenamePipelineEffects r +type InnerRename r = + ( Members RenamePipelineEffects r + , Member (Reader (Module 'Desugared)) r -- the module we're renaming + ) runRenamePipeline :: IsPipeline r => @@ -178,7 +226,8 @@ runRenamePipeline :: Sem (EffectsAsPrefixOf RenamePipelineEffects r) a -> Sem r a runRenamePipeline graph st = - uniqueGenToIO + subsume + . uniqueGenToIO . runReader graph . runErrorOrReport @RenameError . evalState st @@ -189,20 +238,21 @@ qualifyIn mn (MaybeQualified n (Just m)) = do pure $ Qualified n m qualifyIn mn (MaybeQualified n Nothing) = pure $ Qualified n mn -qualifyTypeName :: Rename r => Located (MaybeQualified TypeName) -> Sem r (Located (Qualified TypeName)) +qualifyTypeName :: InnerRename r => Located (MaybeQualified TypeName) -> Sem r (Located (Qualified TypeName)) qualifyTypeName (Located sr (MaybeQualified n (Just m))) = do ensureExistsAndExposed m (Located sr (NTypeName n)) pure $ Located sr (Qualified n m) qualifyTypeName (Located sr (MaybeQualified n Nothing)) = do typeNames' <- use' (field' @"typeNames") + m <- ask case Map.lookup n typeNames' of - Nothing -> throw $ UnknownName (Located sr (NTypeName n)) + Nothing -> throw $ UnknownName (Located sr (NTypeName n)) m typeNames' Just ((Global (Located sr' (Qualified n' m))) :| []) -> pure $ Located sr' (Qualified n' m) Just ((Local _) :| []) -> error "can't have local type names" Just many -> throw $ AmbiguousTypeName (Located sr (NTypeName n)) many lookupGenericName :: - Rename r => + InnerRename r => (Ord name, ToName name) => Lens' RenameState (Map name (NonEmpty (VarRef name))) -> (Located Name -> NonEmpty (VarRef name) -> RenameError) -> @@ -211,17 +261,18 @@ lookupGenericName :: lookupGenericName _ _ (Located sr (MaybeQualified n (Just m))) = do ensureExistsAndExposed m (Located sr (toName n)) pure $ Located sr $ Global (Located sr (Qualified n m)) -lookupGenericName lens err (Located sr (MaybeQualified n Nothing)) = do +lookupGenericName lens ambiguousError (Located sr (MaybeQualified n Nothing)) = do names' <- use' lens - case Map.lookup n names' of - Just (v :| []) -> pure $ Located sr v - Just many -> throw $ err (Located sr $ toName n) many - Nothing -> throw $ UnknownName (Located sr $ toName n) + m <- ask + case maybe [] (NonEmpty.filter ((m `isImportedBy`) . fmap toName)) (Map.lookup n names') of + [v] -> pure $ Located sr v + [] -> throw $ UnknownName (Located sr $ toName n) m names' + (x : xs) -> throw $ ambiguousError (Located sr $ toName n) (x :| xs) -lookupVarName :: Rename r => Located (MaybeQualified VarName) -> Sem r (Located (VarRef VarName)) +lookupVarName :: InnerRename r => Located (MaybeQualified VarName) -> Sem r (Located (VarRef VarName)) lookupVarName = lookupGenericName (field' @"varNames") AmbiguousVarName -lookupTypeName :: Rename r => Located (MaybeQualified TypeName) -> Sem r (Located (Qualified TypeName)) +lookupTypeName :: InnerRename r => Located (MaybeQualified TypeName) -> Sem r (Located (Qualified TypeName)) lookupTypeName n = lookupGenericName (field' @"typeNames") AmbiguousTypeName n <<&>> \case Local _ -> error "can't have local type names" @@ -240,7 +291,8 @@ sortDeclarations :: [RenamedDeclaration] -> Sem r [RenamedDeclaration] sortDeclarations = pure rename :: Rename r => Module 'Desugared -> Sem r (Module 'Renamed) -rename = +rename m = do + Log.debug $ "Renaming module " <> showPretty (m ^. _Unwrapped % unlocated % field' @"name") traverseOf (_Unwrapped % unlocated) ( \m' -> do @@ -248,10 +300,11 @@ rename = traverseOf_ (field' @"declarations" % each) (addDeclarationToContext False) m' -- add our own declarations to field' context exposing' <- renameExposing (m' ^. field' @"name" % unlocated) (m' ^. field' @"exposing") imports' <- traverse renameImport (m' ^. field' @"imports") - declarations' <- traverse renameDeclaration (m' ^. field' @"declarations") + declarations' <- runReader m (traverse renameDeclaration (m' ^. field' @"declarations")) sorted <- sortDeclarations declarations' pure (Module' (m' ^. field' @"name") exposing' imports' sorted) ) + m where renameExposing :: Rename r => ModuleName -> Exposing 'Desugared -> Sem r (Exposing 'Renamed) renameExposing _ ExposingAll = pure ExposingAll @@ -311,14 +364,16 @@ addDeclarationToContext _ decl = do traverseOf_ (each % _1 % unlocated) (\tn -> modify $ over (the @"typeNames") $ insertMerging tn (global tn)) ctors _ -> pass -ensureExistsAndExposed :: Rename r => ModuleName -> Located Name -> Sem r () +-- | Ensure that a name exists in the context and is exposed +ensureExistsAndExposed :: InnerRename r => ModuleName -> Located Name -> Sem r () ensureExistsAndExposed mn n = do modules <- ask + thisMod <- ask case moduleFromName mn modules of Nothing -> throw $ UnknownModule mn Just m -> do unless (elementExistsInModule m (n ^. unlocated)) $ throw $ NonExistentModuleDeclaration mn n - unless (isExposingAndExists m (n ^. unlocated)) $ throw $ UnknownName n + unless (isExposingAndExists m (n ^. unlocated)) $ throw $ UnknownName @Name n thisMod mempty elementExistsInModule :: Module 'Desugared -> Name -> Bool elementExistsInModule m' n' = @@ -331,6 +386,9 @@ elementExistsInModule m' n' = ) (m' ^. _Unwrapped % unlocated % field' @"declarations") +{- | Tests that n is exposed in m +I.e. that it is in the exposing list, or that the module is exposing everything +-} isExposingAndExists :: Module 'Desugared -> Name -> Bool isExposingAndExists m n = let mn = m ^. _Unwrapped % unlocated % field' @"name" % unlocated @@ -344,10 +402,40 @@ isExposingAndExists m n = isExposition mn (NTypeName tn) (ExposedTypeAndAllConstructors tn') = MaybeQualified tn (Just mn) == tn' ^. unlocated isExposition _ _ _ = False -renameDeclaration :: Rename r => DesugaredDeclaration -> Sem r RenamedDeclaration +{- | Tests that m imports n +This is determined by 2 conditions: +n's module name is in the import list of m +n is exposed by the import +-} +isImportedBy :: Module 'Desugared -> VarRef Name -> Bool +isImportedBy m (Local _) = True -- we always assume a local variable exists, even if it doesn't. this condition is checked elsewhere +isImportedBy m (Global (Located _ (Qualified n' nameMod))) = do + (nameMod == m ^. _Unwrapped % unlocated % field' @"name" % unlocated) || isImportedBy' m n' nameMod + where + isImportedBy' :: Module 'Desugared -> Name -> ModuleName -> Bool + isImportedBy' m n' nameMod = do + let mn = m ^. _Unwrapped % unlocated % field' @"name" % unlocated + let imports' = m ^. _Unwrapped % unlocated % field' @"imports" + case findImport nameMod imports' of + Nothing -> False + Just imp -> do + let exposing' = imp ^. _Unwrapped % unlocated % field' @"exposing" + case exposing' of + ExposingAll -> True + ExposingSome es -> any (isExposition mn n') es + findImport :: ModuleName -> [Import 'Desugared] -> Maybe (Import 'Desugared) + findImport mn' = find ((mn' ==) . view (_Unwrapped % unlocated % field' @"importing" % unlocated)) + + isExposition :: ModuleName -> Name -> Exposition 'Desugared -> Bool + isExposition mn (NVarName vn) (ExposedValue vn') = MaybeQualified vn (Just mn) == vn' ^. unlocated + isExposition mn (NTypeName tn) (ExposedType tn') = MaybeQualified tn (Just mn) == tn' ^. unlocated + isExposition mn (NTypeName tn) (ExposedTypeAndAllConstructors tn') = MaybeQualified tn (Just mn) == tn' ^. unlocated + isExposition _ _ _ = False + +renameDeclaration :: InnerRename r => DesugaredDeclaration -> Sem r RenamedDeclaration renameDeclaration decl@(Declaration ld) = Declaration <$> traverseOf unlocated renameDeclaration' ld where - renameDeclaration' :: Rename r => DesugaredDeclaration' -> Sem r RenamedDeclaration' + renameDeclaration' :: InnerRename r => DesugaredDeclaration' -> Sem r RenamedDeclaration' renameDeclaration' fd = do -- qualify the name with the module name let name' = @@ -360,10 +448,10 @@ renameDeclaration decl@(Declaration ld) = Declaration <$> traverseOf unlocated r pure $ Declaration' (fd ^. field' @"moduleName") name' body' - renameDeclarationBody :: (Rename r, Member (Reader (Maybe DesugaredDeclaration)) r) => DesugaredDeclarationBody -> Sem r RenamedDeclarationBody + renameDeclarationBody :: (InnerRename r, Member (Reader (Maybe DesugaredDeclaration)) r) => DesugaredDeclarationBody -> Sem r RenamedDeclarationBody renameDeclarationBody (DeclarationBody ldb) = DeclarationBody <$> traverseOf unlocated renameDeclarationBody' ldb - renameDeclarationBody' :: (Rename r, Member (Reader (Maybe DesugaredDeclaration)) r) => DesugaredDeclarationBody' -> Sem r RenamedDeclarationBody' + renameDeclarationBody' :: (InnerRename r, Member (Reader (Maybe DesugaredDeclaration)) r) => DesugaredDeclarationBody' -> Sem r RenamedDeclarationBody' renameDeclarationBody' (Value val _ ty ann) = scoped $ do ty' <- traverse (traverseOf (_Unwrapped % _1 % unlocated) (renameType True)) ty val' <- renameExpr val @@ -383,7 +471,7 @@ renameDeclaration decl@(Declaration ld) = Declaration <$> traverseOf unlocated r let ann' = coerceTypeDeclAnnotations ann pure $ TypeDeclaration vars' ty' ann' -renameTypeDeclaration :: Rename r => ModuleName -> DesugaredTypeDeclaration -> Sem r RenamedTypeDeclaration +renameTypeDeclaration :: InnerRename r => ModuleName -> DesugaredTypeDeclaration -> Sem r RenamedTypeDeclaration renameTypeDeclaration _ (Alias t) = do t' <- traverseOf (_Unwrapped % _1 % unlocated) (renameType False) t pure $ Alias t' @@ -396,7 +484,7 @@ renameTypeDeclaration thisMod (ADT constructors) = do -- | Renames a type, qualifying type constructors and type variables where necessary renameType :: - Rename r => + InnerRename r => -- | If new type variables are allowed - if False, this will throw an error if a type variable is not in scope -- This is useful for type declarations, where something like @type Invalid a = b@ would clearly be invalid -- But for local type annotations, we want to allow this, as it may be valid @@ -422,7 +510,7 @@ renameType antv (RecordType ln) = RecordType <$> traverse (traverseOf (_2 % _Unw renameType antv (TupleType ts) = TupleType <$> traverse (traverseOf (_Unwrapped % _1 % unlocated) (renameType antv)) ts renameType antv (ListType t) = ListType <$> traverseOf (_Unwrapped % _1 % unlocated) (renameType antv) t -renameExpr :: (Rename r, Member (Reader (Maybe DesugaredDeclaration)) r) => DesugaredExpr -> Sem r RenamedExpr +renameExpr :: (InnerRename r, Member (Reader (Maybe DesugaredDeclaration)) r) => DesugaredExpr -> Sem r RenamedExpr renameExpr (Expr' (Block es)) = desugarBlock es renameExpr e@(Expr' (Let{})) = desugarBlock (e :| []) renameExpr (Expr le@(Located loc _, _)) = @@ -498,10 +586,10 @@ renameExpr (Expr le@(Located loc _, _)) = renameExpr' (Let{}) = error "renameExpr': Let should be handled by renameExpr" renameExpr' (Block{}) = error "renameExpr': Block should be handled by renameExpr" -renameBinaryOperator :: Rename r => DesugaredBinaryOperator -> Sem r RenamedBinaryOperator +renameBinaryOperator :: InnerRename r => DesugaredBinaryOperator -> Sem r RenamedBinaryOperator renameBinaryOperator (MkBinaryOperator op) = MkBinaryOperator <$> traverseOf unlocated renameBinaryOperator' op where - renameBinaryOperator' :: Rename r => DesugaredBinaryOperator' -> Sem r RenamedBinaryOperator' + renameBinaryOperator' :: InnerRename r => DesugaredBinaryOperator' -> Sem r RenamedBinaryOperator' renameBinaryOperator' (SymOp o) = do op' <- lookupVarName (OperatorVarName <<$>> o) let onlyOpName (OperatorVarName o') = o' @@ -520,7 +608,7 @@ renameBinaryOperator (MkBinaryOperator op) = MkBinaryOperator <$> traverseOf unl pure $ Global (ConName <<$>> tn) pure $ Infixed op' -renamePattern :: Rename r => DesugaredPattern -> Sem r RenamedPattern +renamePattern :: InnerRename r => DesugaredPattern -> Sem r RenamedPattern renamePattern (Pattern fp@(Located loc _, _)) = Pattern <$> bitraverse @@ -528,7 +616,7 @@ renamePattern (Pattern fp@(Located loc _, _)) = (traverse (traverseOf (_Unwrapped % _1 % unlocated) (renameType False))) fp where - renamePattern' :: Rename r => DesugaredPattern' -> Sem r RenamedPattern' + renamePattern' :: InnerRename r => DesugaredPattern' -> Sem r RenamedPattern' renamePattern' (IntegerPattern i) = pure $ IntegerPattern i renamePattern' (FloatPattern i) = pure $ FloatPattern i renamePattern' (StringPattern i) = pure $ StringPattern i @@ -583,7 +671,7 @@ patternToVarName (Pattern (Located _ p, _)) = ConsPattern _ -> mn "cons" UnitPattern -> "unit" -patternToMatch :: (Rename r, Member (Reader (Maybe DesugaredDeclaration)) r) => DesugaredPattern -> DesugaredExpr -> Sem r (Located (Unique VarName), RenamedExpr) +patternToMatch :: (InnerRename r, Member (Reader (Maybe DesugaredDeclaration)) r) => DesugaredPattern -> DesugaredExpr -> Sem r (Located (Unique VarName), RenamedExpr) -- Special case, no match needed -- We can just turn \x -> x into \x -> x patternToMatch (Pattern (Located _ (VarPattern vn), _)) body = do @@ -611,12 +699,12 @@ This is a little bit special because patterns have to be converted to match expr For example, @\(a, b) -> a@ becomes @\ab_ -> match ab_ with (a, b) -> a@ -} -renameLambda :: (Rename r, Member (Reader (Maybe DesugaredDeclaration)) r) => DesugaredPattern -> DesugaredExpr -> Sem r RenamedExpr' +renameLambda :: (InnerRename r, Member (Reader (Maybe DesugaredDeclaration)) r) => DesugaredPattern -> DesugaredExpr -> Sem r RenamedExpr' renameLambda p e = do (arg, match) <- patternToMatch p e pure (Lambda arg match) -desugarBlock :: (Rename r, Member (Reader (Maybe DesugaredDeclaration)) r) => NonEmpty DesugaredExpr -> Sem r RenamedExpr +desugarBlock :: (InnerRename r, Member (Reader (Maybe DesugaredDeclaration)) r) => NonEmpty DesugaredExpr -> Sem r RenamedExpr desugarBlock (e@(Expr' (Let{})) :| []) = do decl <- ask @(Maybe DesugaredDeclaration) throw (BlockEndsWithLet e (fmap (view (_Unwrapped % unlocated % the @"body")) decl)) diff --git a/stdlib/prelude.elr b/stdlib/prelude.elr index 0b7e944..c02b473 100644 --- a/stdlib/prelude.elr +++ b/stdlib/prelude.elr @@ -1,5 +1,6 @@ module Prelude import Elara.Prim +import List def (*>) : IO a -> IO b -> IO b let (*>) a b = a >>= \x -> b From bbd9441fda5ca16c4e49e73f6fe10eb1e838f688 Mon Sep 17 00:00:00 2001 From: Alexander Wood Date: Sat, 1 Jun 2024 22:27:41 +0100 Subject: [PATCH 07/12] style(renamer): :rotating_light: Remove unused variable binding --- src/Elara/Rename.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Elara/Rename.hs b/src/Elara/Rename.hs index 238e0b4..525a162 100644 --- a/src/Elara/Rename.hs +++ b/src/Elara/Rename.hs @@ -408,7 +408,7 @@ n's module name is in the import list of m n is exposed by the import -} isImportedBy :: Module 'Desugared -> VarRef Name -> Bool -isImportedBy m (Local _) = True -- we always assume a local variable exists, even if it doesn't. this condition is checked elsewhere +isImportedBy _ (Local _) = True -- we always assume a local variable exists, even if it doesn't. this condition is checked elsewhere isImportedBy m (Global (Located _ (Qualified n' nameMod))) = do (nameMod == m ^. _Unwrapped % unlocated % field' @"name" % unlocated) || isImportedBy' m n' nameMod where From 8936a7c61bf3c4039f63bbd62295716621447c9d Mon Sep 17 00:00:00 2001 From: Alexander Wood Date: Sat, 1 Jun 2024 22:29:34 +0100 Subject: [PATCH 08/12] style(renamer): :lipstick: Slightly reword unknown name error message --- src/Elara/Rename.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Elara/Rename.hs b/src/Elara/Rename.hs index 525a162..11574ea 100644 --- a/src/Elara/Rename.hs +++ b/src/Elara/Rename.hs @@ -112,7 +112,7 @@ instance ReportableError RenameError where ] ] let - prettyVarRef n@(Local{}) = pretty (toName $ view unlocated $ varRefVal n) <+> "(declared locally)" + prettyVarRef n@(Local{}) = pretty (toName $ view unlocated $ varRefVal n) <+> "(local variable)" prettyVarRef (Global (Located _ (Qualified n m))) = pretty (toName n) <+> "(imported from" <+> pretty m <> ")" possibleTypos = let intendedText = nameText n From 8e4d3c07679613ef388837ab2b20db781f7d623a Mon Sep 17 00:00:00 2001 From: Alexander Wood Date: Sat, 1 Jun 2024 22:39:59 +0100 Subject: [PATCH 09/12] feat(renamer): :lipstick: Use code E0001 for unknown name again --- src/Elara/Rename.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Elara/Rename.hs b/src/Elara/Rename.hs index 11574ea..05c7619 100644 --- a/src/Elara/Rename.hs +++ b/src/Elara/Rename.hs @@ -133,7 +133,7 @@ instance ReportableError RenameError where writeReport $ Err - Nothing + (Just Codes.unknownName) ("Unknown" <+> nameKind <+> "name: " <> pretty n) [(n ^. sourceRegion % to sourceRegionToDiagnosePosition, This "referenced here")] (namesThatMightveBeenIntendedButNotImported <> possibleTypos) From 916241968cff7a92feea3441a56161212d308f9e Mon Sep 17 00:00:00 2001 From: Alexander Wood Date: Sat, 1 Jun 2024 22:40:49 +0100 Subject: [PATCH 10/12] fix(renamer): :rotating_light: Fix invalid import --- src/Elara/Rename.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Elara/Rename.hs b/src/Elara/Rename.hs index 05c7619..e88cec3 100644 --- a/src/Elara/Rename.hs +++ b/src/Elara/Rename.hs @@ -29,7 +29,7 @@ import Elara.Data.Pretty import Elara.Data.TopologicalGraph import Elara.Data.Unique (Unique, UniqueGen, makeUnique, uniqueGenToIO) import Elara.Error (ReportableError (report), runErrorOrReport, writeReport) -import Elara.Error.Codes qualified as Codes (nonExistentModuleDeclaration, unknownModule) +import Elara.Error.Codes qualified as Codes import Elara.Pipeline import Elara.Prim.Core (consCtorName, emptyListCtorName) import Error.Diagnose (Marker (This, Where), Note (..), Report (Err)) From 515f6197597b15760811171b8cbb4f92f607fd07 Mon Sep 17 00:00:00 2001 From: Alexander Wood Date: Sat, 1 Jun 2024 23:03:54 +0100 Subject: [PATCH 11/12] refactor(renamer): :recycle: Change renamer to have the current module be _optional_ needed for unit tests to compile (when renaming specific expressions we don't have a whole module) --- src/Elara/Rename.hs | 72 +++++++++++++++++++++++++------------------- test/Infer/Common.hs | 10 ++++-- test/Shunt.hs | 3 +- 3 files changed, 51 insertions(+), 34 deletions(-) diff --git a/src/Elara/Rename.hs b/src/Elara/Rename.hs index e88cec3..6dcd030 100644 --- a/src/Elara/Rename.hs +++ b/src/Elara/Rename.hs @@ -54,7 +54,7 @@ data RenameError -- | The name that was unknown (Located Name) -- | The module we're renaming that the unknown name was referenced in - (Module 'Desugared) + (Maybe (Module 'Desugared)) -- | All known names (Map name (NonEmpty (VarRef name))) | AmbiguousVarName (Located Name) (NonEmpty (VarRef VarName)) @@ -101,35 +101,39 @@ instance ReportableError RenameError where let namesMap = Map.mapKeys toName names let allNames = maybe [] toList (fmap toName <<$>> Map.lookup (n ^. unlocated) namesMap) let namesThatMightveBeenIntendedButNotImported = - case filter (not . isImportedBy m) allNames of - [] -> [] - ns -> - [ Hint $ - vsep - [ "This name is defined in the following modules, but none of them are imported:" - , hsep (punctuate comma (ns ^.. each % _As @"Global" % unlocated % qualifier % to pretty)) - , "Try importing one of the modules." - ] - ] - let - prettyVarRef n@(Local{}) = pretty (toName $ view unlocated $ varRefVal n) <+> "(local variable)" - prettyVarRef (Global (Located _ (Qualified n m))) = pretty (toName n) <+> "(imported from" <+> pretty m <> ")" - possibleTypos = - let intendedText = nameText n - isTypo name = levenshtein (nameText name) intendedText < 3 - typos = - Map.filterWithKey - (\k _ -> isTypo k) - (NonEmpty.filter (\x -> isImportedBy m (toName <$> x)) <$> namesMap) - in case join (Map.elems typos) of + case m of + Nothing -> [] + Just m -> case filter (not . isImportedBy m) allNames of [] -> [] - ts -> + ns -> [ Hint $ vsep - [ "You may have meant one of:" - , listToText (prettyVarRef <$> ts) + [ "This name is defined in the following modules, but none of them are imported:" + , hsep (punctuate comma (ns ^.. each % _As @"Global" % unlocated % qualifier % to pretty)) + , "Try importing one of the modules." ] ] + let + prettyVarRef n@(Local{}) = pretty (toName $ view unlocated $ varRefVal n) <+> "(local variable)" + prettyVarRef (Global (Located _ (Qualified n m))) = pretty (toName n) <+> "(imported from" <+> pretty m <> ")" + possibleTypos = case m of + Nothing -> [] + Just m -> + let intendedText = nameText n + isTypo name = levenshtein (nameText name) intendedText < 3 + typos = + Map.filterWithKey + (\k _ -> isTypo k) + (NonEmpty.filter (\x -> isImportedBy m (toName <$> x)) <$> namesMap) + in case join (Map.elems typos) of + [] -> [] + ts -> + [ Hint $ + vsep + [ "You may have meant one of:" + , listToText (prettyVarRef <$> ts) + ] + ] writeReport $ Err @@ -216,7 +220,7 @@ type RenamePipelineEffects = type Rename r = Members RenamePipelineEffects r type InnerRename r = ( Members RenamePipelineEffects r - , Member (Reader (Module 'Desugared)) r -- the module we're renaming + , Member (Reader (Maybe (Module 'Desugared))) r -- the module we're renaming ) runRenamePipeline :: @@ -264,10 +268,16 @@ lookupGenericName _ _ (Located sr (MaybeQualified n (Just m))) = do lookupGenericName lens ambiguousError (Located sr (MaybeQualified n Nothing)) = do names' <- use' lens m <- ask - case maybe [] (NonEmpty.filter ((m `isImportedBy`) . fmap toName)) (Map.lookup n names') of - [v] -> pure $ Located sr v - [] -> throw $ UnknownName (Located sr $ toName n) m names' - (x : xs) -> throw $ ambiguousError (Located sr $ toName n) (x :| xs) + case m of + Nothing -> + case Map.lookup n names' of + Nothing -> throw $ UnknownName (Located sr $ toName n) m names' + Just (v :| []) -> pure $ Located sr v + Just many -> throw $ ambiguousError (Located sr $ toName n) many + Just m -> case maybe [] (NonEmpty.filter ((m `isImportedBy`) . fmap toName)) (Map.lookup n names') of + [v] -> pure $ Located sr v + [] -> throw $ UnknownName (Located sr $ toName n) (Just m) names' + (x : xs) -> throw $ ambiguousError (Located sr $ toName n) (x :| xs) lookupVarName :: InnerRename r => Located (MaybeQualified VarName) -> Sem r (Located (VarRef VarName)) lookupVarName = lookupGenericName (field' @"varNames") AmbiguousVarName @@ -300,7 +310,7 @@ rename m = do traverseOf_ (field' @"declarations" % each) (addDeclarationToContext False) m' -- add our own declarations to field' context exposing' <- renameExposing (m' ^. field' @"name" % unlocated) (m' ^. field' @"exposing") imports' <- traverse renameImport (m' ^. field' @"imports") - declarations' <- runReader m (traverse renameDeclaration (m' ^. field' @"declarations")) + declarations' <- runReader (Just m) (traverse renameDeclaration (m' ^. field' @"declarations")) sorted <- sortDeclarations declarations' pure (Module' (m' ^. field' @"name") exposing' imports' sorted) ) diff --git a/test/Infer/Common.hs b/test/Infer/Common.hs index bc01a88..a700e1d 100644 --- a/test/Infer/Common.hs +++ b/test/Infer/Common.hs @@ -39,7 +39,6 @@ import Polysemy.Log import Polysemy.Reader (runReader) import Polysemy.State (State) import Print (showPretty) -import Test.HUnit (assertFailure) pattern Forall' :: UniqueTyVar -> Domain -> Type () -> Type () pattern Forall' name domain t = Forall () () name domain t @@ -65,7 +64,14 @@ inferFully source = finalisePipeline . runInferPipeline . runShuntPipeline . run tokens <- readTokensWith fp (toString source) parsed <- parsePipeline exprParser fp (toString source, tokens) desugared <- runDesugarPipeline $ runDesugar $ desugarExpr parsed - renamed <- runRenamePipeline (createGraph []) primitiveRenameState (runReader Nothing $ renameExpr desugared) + renamed <- + runRenamePipeline + (createGraph []) + primitiveRenameState + ( runReader (Nothing @(Module 'Desugared)) $ + runReader (Nothing @(Declaration 'Desugared)) $ + renameExpr desugared + ) shunted <- runReader mempty $ shuntExpr renamed inferExpression shunted Nothing >>= completeInference diff --git a/test/Shunt.hs b/test/Shunt.hs index bf34116..4b987f1 100644 --- a/test/Shunt.hs +++ b/test/Shunt.hs @@ -4,6 +4,7 @@ import Common (diagShouldSucceed) import Elara.AST.Generic import Elara.AST.Generic.Instances () import Elara.AST.Generic.Pattern (functionCall, int, var) +import Elara.AST.Module import Elara.AST.Name (OpName (..), Qualified (..), VarName (OperatorVarName)) import Elara.AST.Region (generatedLocated) import Elara.AST.Select (LocatedAST (..), UnlocatedAST (UnlocatedShunted)) @@ -33,7 +34,7 @@ loadExpr source = finalisePipeline . runShuntPipeline . runRenamePipeline (creat parsed <- parsePipeline exprParser fp (toString source, tokens) desugared <- runDesugarPipeline $ runDesugar $ desugarExpr parsed - renamed <- runReader Nothing $ renameExpr desugared + renamed <- runReader Nothing $ runReader (Nothing :: Maybe (Module 'Desugared)) $ renameExpr desugared runReader fakeOperatorTable $ fixExpr renamed mkFakeVar :: OpName -> VarRef VarName From 8dca1bb1d6a90ac20d867fb056d54ac809d0b844 Mon Sep 17 00:00:00 2001 From: Alexander Wood Date: Sat, 1 Jun 2024 23:28:41 +0100 Subject: [PATCH 12/12] ci(changelog): Add release script --- release.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 release.sh diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..438d19b --- /dev/null +++ b/release.sh @@ -0,0 +1,30 @@ +# inspired by https://github.com/orhun/git-cliff/blob/main/release.sh + +new_version=$(git cliff --bumped-version) +echo "New version: $new_version" + +# update package.yaml version +sed -E -i '' "s/^version: \"[^\"]*\"$/version: \"${new_version#v}\"/" package.yaml +# and the cabal file +hpack + + +# Update changelog +git cliff --tag "${new_version}" > CHANGELOG.md +git add -A && git commit -m "chore(release): prepare for ${new_version}" +git show + +# generate a changelog for the tag message +export GIT_CLIFF_TEMPLATE="\ + {% for group, commits in commits | group_by(attribute=\"group\") %} + {{ group | upper_first }}\ + {% for commit in commits %} + - {% if commit.breaking %}(breaking) {% endif %}{{ commit.message | upper_first }} ({{ commit.id | truncate(length=7, end=\"\") }})\ + {% endfor %} + {% endfor %}" +changelog=$(git cliff --unreleased --strip all) + +git tag -s -a "${new_version}" -m "Release ${new_version}" -m "${changelog}" +git tag -v "${new_version}" + +echo "Release ready. Run 'git push --follow-tags' to push the changes and tags."