From d0c97bf7b14851d1315451c64caa20f5fce0e8e7 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 5 Dec 2024 00:59:19 +0300 Subject: [PATCH 1/7] fix(eo-phi-normalizer): correctly handle ExitSuccess --- eo-phi-normalizer/Setup.hs | 13 +++++++------ eo-phi-normalizer/src/Language/EO/Locale.hs | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/eo-phi-normalizer/Setup.hs b/eo-phi-normalizer/Setup.hs index 1223ac13..93243d2c 100644 --- a/eo-phi-normalizer/Setup.hs +++ b/eo-phi-normalizer/Setup.hs @@ -32,7 +32,7 @@ -- for the parsers included in Ogma. module Main (main) where -import Control.Exception (SomeException, catch, displayException, evaluate) +import Control.Exception (Handler (..), SomeException, catches, displayException, evaluate) import Data.ByteString as BS (readFile, writeFile) import Data.List (intercalate) import Data.Text (Text) @@ -55,11 +55,12 @@ withCorrectLocale :: IO a -> IO a withCorrectLocale act = do let withCorrectLocale' = withCP65001 . withUtf8 withCorrectLocale' act - `catch` ( \(x :: SomeException) -> - withCorrectLocale' do - putStrLn (displayException x) - exitWith (ExitFailure 1) - ) + `catches` [ Handler $ \(x :: ExitCode) -> exitWith x + , Handler $ \(x :: SomeException) -> + withCorrectLocale' do + putStrLn (displayException x) + exitWith (ExitFailure 1) + ] -- | Run BNFC, happy, and alex on the grammar before the actual build step. -- diff --git a/eo-phi-normalizer/src/Language/EO/Locale.hs b/eo-phi-normalizer/src/Language/EO/Locale.hs index f6e5717e..071229f1 100644 --- a/eo-phi-normalizer/src/Language/EO/Locale.hs +++ b/eo-phi-normalizer/src/Language/EO/Locale.hs @@ -26,7 +26,7 @@ module Language.EO.Locale where -import Control.Exception (Exception (..), SomeException, catch) +import Control.Exception (Exception (..), Handler (..), SomeException, catches) import Main.Utf8 (withUtf8) import System.Exit (ExitCode (..), exitWith) import System.IO.CodePage (withCP65001) @@ -35,8 +35,9 @@ withCorrectLocale :: IO a -> IO a withCorrectLocale act = do let withCorrectLocale' = withCP65001 . withUtf8 withCorrectLocale' act - `catch` ( \(x :: SomeException) -> - withCorrectLocale' do - putStrLn (displayException x) - exitWith (ExitFailure 1) - ) + `catches` [ Handler $ \(x :: ExitCode) -> exitWith x + , Handler $ \(x :: SomeException) -> + withCorrectLocale' do + putStrLn (displayException x) + exitWith (ExitFailure 1) + ] From e6ca983ca3399d737640787a167cffd101d9de95 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 5 Dec 2024 01:00:43 +0300 Subject: [PATCH 2/7] fix(flake): - don't run mdsh in the root directory - exit update-markdown script on the first error --- flake.nix | 2 +- scripts/update-markdown.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index c21f540d..fdaefb6b 100644 --- a/flake.nix +++ b/flake.nix @@ -199,7 +199,7 @@ let name = "update-markdown"; text = '' - mdsh + set -ex ${lib.concatMapStringsSep "\n" (x: "mdsh -i site/docs/src/${x} --work_dir .") [ "common/celsius.md" diff --git a/scripts/update-markdown.sh b/scripts/update-markdown.sh index 1c98cd17..89f3c357 100755 --- a/scripts/update-markdown.sh +++ b/scripts/update-markdown.sh @@ -25,7 +25,7 @@ # This file was generated automatically. # You can edit the script in 'flake.nix' -mdsh +set -ex mdsh -i site/docs/src/common/celsius.md --work_dir . mdsh -i site/docs/src/eo-phi-normalizer.md --work_dir . From 1c5816e71b3388c9212ac757d02ede3fa62abbb1 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 5 Dec 2024 01:03:41 +0300 Subject: [PATCH 3/7] fix(site): use correct bindings path --- site/docs/src/eo-phi-normalizer/metrics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/docs/src/eo-phi-normalizer/metrics.md b/site/docs/src/eo-phi-normalizer/metrics.md index 293a0152..049893ff 100644 --- a/site/docs/src/eo-phi-normalizer/metrics.md +++ b/site/docs/src/eo-phi-normalizer/metrics.md @@ -73,7 +73,7 @@ cat celsius.phi | eo-phi-normalizer metrics ### `--bindings-path` ```$ as console -eo-phi-normalizer metrics --bindings-path org.eolang celsius.phi +eo-phi-normalizer metrics --bindings-path '' celsius.phi ``` ```console From 35a74e638589389751b7cb53519792a38c951ae4 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 5 Dec 2024 01:31:50 +0300 Subject: [PATCH 4/7] fix(flake): file path --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index fdaefb6b..35500ebe 100644 --- a/flake.nix +++ b/flake.nix @@ -215,7 +215,7 @@ "contributing.md" ]} - cp site/docs/docs/markdown/contributing.md CONTRIBUTING.md + cp site/docs/src/contributing.md CONTRIBUTING.md rm celsius.phi From d2102906e1cc1bfbd7b125290a977fc04c26ea68 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 5 Dec 2024 01:32:54 +0300 Subject: [PATCH 5/7] fix(contributing): don't use mdsh features to include a file --- CONTRIBUTING.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9eba5571..1340524a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,6 +14,10 @@ Check open issues ([link](https://github.com/objectionary/eo-phi-normalizer/issu ## Enter the repository + + + + Clone and enter the project repository. ```sh @@ -21,6 +25,8 @@ git clone https://github.com/objectionary/eo-phi-normalizer --recurse-submodules cd eo-phi-normalizer ``` + + ## Install stack We recommend using [stack](https://docs.haskellstack.org/en/stable) for quick local development and testing. From d489d7e030acba645108bf7e4dac2de26dc8a5fd Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 5 Dec 2024 01:43:46 +0300 Subject: [PATCH 6/7] fix(scripts): update --- scripts/update-markdown.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update-markdown.sh b/scripts/update-markdown.sh index 89f3c357..d9e373e7 100755 --- a/scripts/update-markdown.sh +++ b/scripts/update-markdown.sh @@ -39,7 +39,7 @@ mdsh -i site/docs/src/eo-phi-normalizer/print-rules.md --work_dir . mdsh -i site/docs/src/eo-phi-normalizer/test.md --work_dir . mdsh -i site/docs/src/contributing.md --work_dir . -cp site/docs/docs/markdown/contributing.md CONTRIBUTING.md +cp site/docs/src/contributing.md CONTRIBUTING.md rm celsius.phi From fe340ca87a41135c2284b483065c4bd2651fe9f7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 4 Dec 2024 22:52:04 +0000 Subject: [PATCH 7/7] Update Markdown files --- site/docs/src/eo-phi-normalizer/metrics.md | 47 +++++++++++++--------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/site/docs/src/eo-phi-normalizer/metrics.md b/site/docs/src/eo-phi-normalizer/metrics.md index 049893ff..646be075 100644 --- a/site/docs/src/eo-phi-normalizer/metrics.md +++ b/site/docs/src/eo-phi-normalizer/metrics.md @@ -18,7 +18,7 @@ eo-phi-normalizer metrics --help ```console Usage: eo-phi-normalizer metrics [FILE] [-o|--output-file FILE] - [-b|--bindings-path PATH] + [-b|--bindings-path PATH] Collect metrics for a PHI program. @@ -44,10 +44,10 @@ eo-phi-normalizer metrics celsius.phi { "bindings-by-path-metrics": null, "program-metrics": { - "applications": 3, - "dataless": 6, - "dispatches": 6, - "formations": 8 + "applications": 4, + "dataless": 1, + "dispatches": 9, + "formations": 3 } } ``` @@ -62,10 +62,10 @@ cat celsius.phi | eo-phi-normalizer metrics { "bindings-by-path-metrics": null, "program-metrics": { - "applications": 3, - "dataless": 6, - "dispatches": 6, - "formations": 8 + "applications": 4, + "dataless": 1, + "dispatches": 9, + "formations": 3 } } ``` @@ -82,21 +82,30 @@ eo-phi-normalizer metrics --bindings-path '' celsius.phi "bindings-metrics": [ { "metrics": { - "applications": 0, - "dataless": 3, - "dispatches": 0, - "formations": 3 + "applications": 2, + "dataless": 0, + "dispatches": 6, + "formations": 0 }, - "name": "float" + "name": "c" + }, + { + "metrics": { + "applications": 2, + "dataless": 0, + "dispatches": 3, + "formations": 2 + }, + "name": "result" } ], - "path": "org.eolang" + "path": "" }, "program-metrics": { - "applications": 3, - "dataless": 6, - "dispatches": 6, - "formations": 8 + "applications": 4, + "dataless": 1, + "dispatches": 9, + "formations": 3 } } ```