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. 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) + ] diff --git a/flake.nix b/flake.nix index c21f540d..35500ebe 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" @@ -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 diff --git a/scripts/update-markdown.sh b/scripts/update-markdown.sh index 1c98cd17..d9e373e7 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 . @@ -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 diff --git a/site/docs/src/eo-phi-normalizer/metrics.md b/site/docs/src/eo-phi-normalizer/metrics.md index 293a0152..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 } } ``` @@ -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 @@ -82,21 +82,30 @@ eo-phi-normalizer metrics --bindings-path org.eolang 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 } } ```