From 30a402e7f6dc353f94150707ad1b35ef52cd3fad Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Fri, 29 Nov 2024 19:44:45 +0300 Subject: [PATCH 01/20] feat(eo-phi-normalizer): add simple unicode escaping --- eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs b/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs index c641134aa..f5f234610 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs @@ -27,6 +27,7 @@ {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE GeneralisedNewtypeDeriving #-} {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-orphans #-} @@ -39,7 +40,7 @@ import Control.Arrow (Arrow (first)) import Control.Monad import Data.ByteString (ByteString) import Data.ByteString qualified as ByteString.Strict -import Data.Char (toUpper) +import Data.Char (ord, toUpper) import Data.HashMap.Strict qualified as HashMap import Data.List (intercalate, minimumBy, nubBy, sortOn) import Data.List.NonEmpty (NonEmpty (..), (<|)) @@ -52,6 +53,7 @@ import Language.EO.Phi.Syntax.Abs import Language.EO.Phi.Syntax.Lex (Token) import Language.EO.Phi.Syntax.Par import Numeric (readHex, showHex) +import PyF (fmt) -- $setup -- >>> :set -XOverloadedStrings @@ -78,8 +80,11 @@ parseWith parser input = parser tokens unsafeParseWith :: ([Token] -> Either String a) -> String -> a unsafeParseWith parser input = case parseWith parser input of - Left parseError -> error (parseError <> "\non input\n" <> input <> "\n") + Left parseError -> error (escapeNonASCII parseError <> "\non input\n" <> escapeNonASCII input <> "\n") Right object -> object + where + escapeNonASCII :: String -> String + escapeNonASCII = foldMap (\x -> if ord x < 256 then [x] else [fmt|\\{ord x}|]) -- | State of evaluation is not needed yet, but it might be in the future type EvaluationState = () From 3d9fad429b4eee120191836c959909c846ef3a42 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 29 Nov 2024 16:53:05 +0000 Subject: [PATCH 02/20] Update Markdown files --- site/docs/src/eo-phi-normalizer/rewrite.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/site/docs/src/eo-phi-normalizer/rewrite.md b/site/docs/src/eo-phi-normalizer/rewrite.md index 921416b92..ef200ba6d 100644 --- a/site/docs/src/eo-phi-normalizer/rewrite.md +++ b/site/docs/src/eo-phi-normalizer/rewrite.md @@ -23,8 +23,9 @@ eo-phi-normalizer rewrite --help ```console Usage: eo-phi-normalizer rewrite [-r|--rules FILE] [-c|--chain] [-j|--json] [--tex] [-o|--output-file FILE] [-s|--single] - [--max-depth INT] [--max-growth-factor INT] - [FILE] [-d|--dependency-file FILE] + [-l|--single-line] [--max-depth INT] + [--max-growth-factor INT] [FILE] + [-d|--dependency-file FILE] Rewrite a PHI program. @@ -37,6 +38,8 @@ Available options: -o,--output-file FILE Output to FILE. When this option is not specified, output to stdout. -s,--single Output a single expression. + -l,--single-line Output a single expression on a single line. Has + effect only if the --single is enabled. --max-depth INT Maximum depth of rules application. Defaults to 10. --max-growth-factor INT The factor by which to allow the input term to grow before stopping. Defaults to 10. From ad9654f6927317929413e326166d2ae1f5ece417 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Mon, 2 Dec 2024 22:33:23 +0300 Subject: [PATCH 03/20] refactor(eo-phi-normalizer): share modified parsing error message --- eo-phi-normalizer/src/Language/EO/Phi.hs | 5 ++--- eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/eo-phi-normalizer/src/Language/EO/Phi.hs b/eo-phi-normalizer/src/Language/EO/Phi.hs index e055a36c2..055295d44 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi.hs @@ -36,13 +36,12 @@ import Language.EO.Phi.Syntax.Abs qualified as Phi import Language.EO.Phi.Syntax.Par qualified as Phi import Language.EO.Phi.Normalize +import Language.EO.Phi.Rules.Common (parseWith) import Language.EO.Phi.Syntax -- | Parse a 'Program' or return a parsing error. parseProgram :: String -> Either String Phi.Program -parseProgram input = Phi.pProgram tokens - where - tokens = Phi.myLexer input +parseProgram = parseWith Phi.pProgram -- | Parse an 'Object' or return a parsing error. parseObject :: String -> Either String Phi.Object diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs b/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs index f5f234610..804fe11e7 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs @@ -71,20 +71,20 @@ instance IsString ObjectHead where fromString = unsafeParseWith pObjectHead instance IsString MetaId where fromString = unsafeParseWith pMetaId parseWith :: ([Token] -> Either String a) -> String -> Either String a -parseWith parser input = parser tokens +parseWith parser input = either (\x -> Left (escapeNonASCII [fmt|{x}\non the input:\n{input}|])) Right parsed where tokens = myLexer input + parsed = parser tokens + escapeNonASCII :: String -> String + escapeNonASCII = foldMap (\x -> if ord x < 256 then [x] else [fmt|\\{ord x}|]) -- | Parse a 'Object' from a 'String'. -- May throw an 'error` if input has a syntactical or lexical errors. unsafeParseWith :: ([Token] -> Either String a) -> String -> a unsafeParseWith parser input = case parseWith parser input of - Left parseError -> error (escapeNonASCII parseError <> "\non input\n" <> escapeNonASCII input <> "\n") + Left parseError -> error parseError Right object -> object - where - escapeNonASCII :: String -> String - escapeNonASCII = foldMap (\x -> if ord x < 256 then [x] else [fmt|\\{ord x}|]) -- | State of evaluation is not needed yet, but it might be in the future type EvaluationState = () From 14650a0cdc282569f4638ace90cfc4b3cb36ddf8 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 3 Dec 2024 21:49:02 +0300 Subject: [PATCH 04/20] feat(eo-phi-normalizer): - use UTF-8 in Setup.hs - set code page on Windows using a library --- eo-phi-normalizer/Setup.hs | 30 ++++++++++++++--------- eo-phi-normalizer/app/Main.hs | 5 ++-- eo-phi-normalizer/eo-phi-normalizer.cabal | 9 +++++++ eo-phi-normalizer/package.yaml | 5 ++++ 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/eo-phi-normalizer/Setup.hs b/eo-phi-normalizer/Setup.hs index f3577e176..0367834d8 100644 --- a/eo-phi-normalizer/Setup.hs +++ b/eo-phi-normalizer/Setup.hs @@ -21,8 +21,11 @@ -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. {- FOURMOLU_ENABLE -} + {-# LANGUAGE CPP #-} {-# LANGUAGE QuasiQuotes #-} +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE OverloadedStrings #-} -- Source: https://github.com/haskell/cabal/issues/6726#issuecomment-918663262 @@ -33,17 +36,27 @@ module Main (main) where import Data.List (intercalate) import Distribution.Simple (defaultMainWithHooks, hookedPrograms, postConf, preBuild, simpleUserHooks) import Distribution.Simple.Program (Program (..), findProgramVersion, simpleProgram) -import PyF (fmt) import System.Exit (ExitCode (..)) import System.Process (callCommand) -import Text.Printf (printf) import Control.Exception (evaluate) +import Main.Utf8 (withUtf8) +import System.IO.CodePage (withCP65001) +import Data.ByteString as BS (readFile, writeFile) +import Data.Text (Text) +import Data.Text.Encoding (decodeUtf8, encodeUtf8) +import PyF (fmt) + +readFile' :: FilePath -> IO Text +readFile' = (decodeUtf8 <$>) . BS.readFile + +writeFile' :: FilePath -> Text -> IO () +writeFile' path = BS.writeFile path . encodeUtf8 -- | Run BNFC, happy, and alex on the grammar before the actual build step. -- -- All options for bnfc are hard-coded here. main :: IO () -main = +main = withCP65001 . withUtf8 $ defaultMainWithHooks $ simpleUserHooks { hookedPrograms = [bnfcProgram] @@ -58,16 +71,11 @@ main = -- See the details on the command form in https://github.com/objectionary/eo-phi-normalizer/issues/347#issuecomment-2117097070 addLicense :: FilePath -> IO () addLicense file = do - let readFile' path = do - content <- readFile path - evaluate (length content) - pure content - targetFile = "src/Language/EO/Phi/Syntax/" <> file + let targetFile = "src/Language/EO/Phi/Syntax/" <> file license <- readFile' "LICENSE" - let licenseFormatted = printf "{-\n%s-}\n\n" license + let licenseFormatted = [fmt|{{-\n{license}-}}\n\n|] :: Text code <- readFile' targetFile - evaluate (length license) - writeFile targetFile (licenseFormatted <> code) + writeFile' targetFile (licenseFormatted <> code) command = intercalate "; " $ [ "set -ex" ] <> diff --git a/eo-phi-normalizer/app/Main.hs b/eo-phi-normalizer/app/Main.hs index 4f15d6637..5b9a2efad 100644 --- a/eo-phi-normalizer/app/Main.hs +++ b/eo-phi-normalizer/app/Main.hs @@ -83,7 +83,7 @@ import Language.EO.Phi.Rules.RunYegor (yegorRuleSet) import Language.EO.Phi.Rules.Yaml (RuleSet (rules, title), convertRuleNamed, parseRuleSetFromFile) import Language.EO.Phi.ToLaTeX import Language.EO.Test.YamlSpec (spec) -import Main.Utf8 +import Main.Utf8 (withUtf8) import Options.Applicative hiding (metavar) import Options.Applicative qualified as Optparse (metavar) import Paths_eo_phi_normalizer (version) @@ -91,6 +91,7 @@ import PyF (fmt, fmtTrim) import System.Directory (createDirectoryIfMissing, doesFileExist) import System.FilePath (takeDirectory) import System.IO (IOMode (WriteMode), getContents', hFlush, hPutStr, hPutStrLn, openFile, stdout) +import System.IO.CodePage (withCP65001) import Test.Hspec.Core.Runner data CLI'RewritePhi = CLI'RewritePhi @@ -562,7 +563,7 @@ wrapRawBytesIn = \case -- * Main main :: IO () -main = withUtf8 do +main = (withCP65001 . withUtf8) do opts <- customExecParser pprefs (cliOpts (showVersion version)) let printAsProgramOrAsObject = \case Formation bindings' -> printTree $ Program bindings' diff --git a/eo-phi-normalizer/eo-phi-normalizer.cabal b/eo-phi-normalizer/eo-phi-normalizer.cabal index 214dba1a2..ff41d522c 100644 --- a/eo-phi-normalizer/eo-phi-normalizer.cabal +++ b/eo-phi-normalizer/eo-phi-normalizer.cabal @@ -202,7 +202,12 @@ custom-setup Cabal >=2.4.0.1 && <4.0 , PyF , base >=4.11.0.0 && <5.0 + , bytestring + , code-page + , extra , process >=1.6.3.0 + , text + , with-utf8 library exposed-modules: @@ -255,6 +260,7 @@ library , blaze-markup , bytestring , cereal + , code-page , containers , directory , file-embed >=0.0.16.0 @@ -297,6 +303,7 @@ executable eo-phi-normalizer , blaze-markup , bytestring , cereal + , code-page , containers , directory , eo-phi-normalizer @@ -371,6 +378,7 @@ test-suite doctests , blaze-markup , bytestring , cereal + , code-page , containers , directory , doctest-parallel @@ -423,6 +431,7 @@ test-suite spec , blaze-markup , bytestring , cereal + , code-page , containers , directory , eo-phi-normalizer diff --git a/eo-phi-normalizer/package.yaml b/eo-phi-normalizer/package.yaml index fbd0ce0bf..fa150bbb9 100644 --- a/eo-phi-normalizer/package.yaml +++ b/eo-phi-normalizer/package.yaml @@ -53,8 +53,12 @@ custom-setup: dependencies: - base >= 4.11.0.0 && < 5.0 - Cabal >= 2.4.0.1 && < 4.0 + - code-page - process >= 1.6.3.0 + - text - PyF + - bytestring + - with-utf8 build-tools: alex: ">= 3.2.4" @@ -86,6 +90,7 @@ dependencies: - hashable - unordered-containers - containers + - code-page default-extensions: - ImportQualifiedPost From 406aa8efdef43fe8cdf5d0a353e567964ec4aa72 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 3 Dec 2024 22:43:03 +0300 Subject: [PATCH 05/20] fix(eo-phi-normalizer): don't escape Unicode in errors --- eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs b/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs index 804fe11e7..221420517 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs @@ -40,7 +40,7 @@ import Control.Arrow (Arrow (first)) import Control.Monad import Data.ByteString (ByteString) import Data.ByteString qualified as ByteString.Strict -import Data.Char (ord, toUpper) +import Data.Char (toUpper) import Data.HashMap.Strict qualified as HashMap import Data.List (intercalate, minimumBy, nubBy, sortOn) import Data.List.NonEmpty (NonEmpty (..), (<|)) @@ -71,12 +71,10 @@ instance IsString ObjectHead where fromString = unsafeParseWith pObjectHead instance IsString MetaId where fromString = unsafeParseWith pMetaId parseWith :: ([Token] -> Either String a) -> String -> Either String a -parseWith parser input = either (\x -> Left (escapeNonASCII [fmt|{x}\non the input:\n{input}|])) Right parsed +parseWith parser input = either (\x -> Left [fmt|{x}\non the input:\n{input}|]) Right parsed where tokens = myLexer input parsed = parser tokens - escapeNonASCII :: String -> String - escapeNonASCII = foldMap (\x -> if ord x < 256 then [x] else [fmt|\\{ord x}|]) -- | Parse a 'Object' from a 'String'. -- May throw an 'error` if input has a syntactical or lexical errors. From 45836bf41a785103cec6c78f4afee02e94d68673 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 3 Dec 2024 22:50:56 +0300 Subject: [PATCH 06/20] refactor(eo-phi-normalizer): use a single list of strings --- eo-phi-normalizer/Setup.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/eo-phi-normalizer/Setup.hs b/eo-phi-normalizer/Setup.hs index 0367834d8..dca2b4c5c 100644 --- a/eo-phi-normalizer/Setup.hs +++ b/eo-phi-normalizer/Setup.hs @@ -77,15 +77,15 @@ main = withCP65001 . withUtf8 $ code <- readFile' targetFile writeFile' targetFile (licenseFormatted <> code) - command = intercalate "; " $ - [ "set -ex" ] <> - [ "chcp.com" | isWindows ] <> - [ "chcp.com 65001" | isWindows ] <> - [ "bnfc --haskell -d -p Language.EO.Phi --generic -o src/ grammar/EO/Phi/Syntax.cf"] <> - [ "cd src/Language/EO/Phi/Syntax" ] <> - [ "alex Lex.x" ] <> - [ "happy Par.y" ] <> - [ "true" ] + -- See the details on the command form in https://github.com/objectionary/eo-phi-normalizer/issues/347#issuecomment-2117097070 + command = intercalate "; "$ + [ "set -ex" + , "bnfc --haskell -d -p Language.EO.Phi --generic -o src/ grammar/EO/Phi/Syntax.cf" + , "cd src/Language/EO/Phi/Syntax" + , "alex Lex.x" + , "happy Par.y" + , "true" + ] fullCommand = [fmt|bash -c ' {command} '|] From 8131c1c28f52f086d5f36564cd148061f93d09f4 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 3 Dec 2024 22:51:23 +0300 Subject: [PATCH 07/20] fix(eo-phi-normalizer): remove pragmas --- eo-phi-normalizer/Setup.hs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/eo-phi-normalizer/Setup.hs b/eo-phi-normalizer/Setup.hs index dca2b4c5c..98c28ce1d 100644 --- a/eo-phi-normalizer/Setup.hs +++ b/eo-phi-normalizer/Setup.hs @@ -22,7 +22,6 @@ -- SOFTWARE. {- FOURMOLU_ENABLE -} -{-# LANGUAGE CPP #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE BlockArguments #-} {-# LANGUAGE OverloadedStrings #-} @@ -62,13 +61,6 @@ main = withCP65001 . withUtf8 $ { hookedPrograms = [bnfcProgram] , postConf = \args flags packageDesc localBuildInfo -> do let - isWindows = -#ifdef mingw32_HOST_OS - True -#else - False -#endif - -- See the details on the command form in https://github.com/objectionary/eo-phi-normalizer/issues/347#issuecomment-2117097070 addLicense :: FilePath -> IO () addLicense file = do let targetFile = "src/Language/EO/Phi/Syntax/" <> file From 7b92de478ba4848fc96db71c1c90d1488d561ee0 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 3 Dec 2024 22:51:59 +0300 Subject: [PATCH 08/20] refactor(eo-phi-normalizer): format --- eo-phi-normalizer/Setup.hs | 86 +++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/eo-phi-normalizer/Setup.hs b/eo-phi-normalizer/Setup.hs index 98c28ce1d..63712bcfc 100644 --- a/eo-phi-normalizer/Setup.hs +++ b/eo-phi-normalizer/Setup.hs @@ -22,9 +22,9 @@ -- SOFTWARE. {- FOURMOLU_ENABLE -} -{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE BlockArguments #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE QuasiQuotes #-} -- Source: https://github.com/haskell/cabal/issues/6726#issuecomment-918663262 @@ -32,18 +32,18 @@ -- for the parsers included in Ogma. module Main (main) where -import Data.List (intercalate) -import Distribution.Simple (defaultMainWithHooks, hookedPrograms, postConf, preBuild, simpleUserHooks) -import Distribution.Simple.Program (Program (..), findProgramVersion, simpleProgram) -import System.Exit (ExitCode (..)) -import System.Process (callCommand) import Control.Exception (evaluate) -import Main.Utf8 (withUtf8) -import System.IO.CodePage (withCP65001) import Data.ByteString as BS (readFile, writeFile) +import Data.List (intercalate) import Data.Text (Text) import Data.Text.Encoding (decodeUtf8, encodeUtf8) +import Distribution.Simple (defaultMainWithHooks, hookedPrograms, postConf, preBuild, simpleUserHooks) +import Distribution.Simple.Program (Program (..), findProgramVersion, simpleProgram) +import Main.Utf8 (withUtf8) import PyF (fmt) +import System.Exit (ExitCode (..)) +import System.IO.CodePage (withCP65001) +import System.Process (callCommand) readFile' :: FilePath -> IO Text readFile' = (decodeUtf8 <$>) . BS.readFile @@ -55,40 +55,42 @@ writeFile' path = BS.writeFile path . encodeUtf8 -- -- All options for bnfc are hard-coded here. main :: IO () -main = withCP65001 . withUtf8 $ - defaultMainWithHooks $ - simpleUserHooks - { hookedPrograms = [bnfcProgram] - , postConf = \args flags packageDesc localBuildInfo -> do - let - addLicense :: FilePath -> IO () - addLicense file = do - let targetFile = "src/Language/EO/Phi/Syntax/" <> file - license <- readFile' "LICENSE" - let licenseFormatted = [fmt|{{-\n{license}-}}\n\n|] :: Text - code <- readFile' targetFile - writeFile' targetFile (licenseFormatted <> code) - - -- See the details on the command form in https://github.com/objectionary/eo-phi-normalizer/issues/347#issuecomment-2117097070 - command = intercalate "; "$ - [ "set -ex" - , "bnfc --haskell -d -p Language.EO.Phi --generic -o src/ grammar/EO/Phi/Syntax.cf" - , "cd src/Language/EO/Phi/Syntax" - , "alex Lex.x" - , "happy Par.y" - , "true" - ] - - fullCommand = [fmt|bash -c ' {command} '|] - - putStrLn fullCommand - - _ <- callCommand fullCommand - _ <- addLicense "Abs.hs" - _ <- addLicense "Print.hs" - - postConf simpleUserHooks args flags packageDesc localBuildInfo - } +main = + withCP65001 . withUtf8 $ + defaultMainWithHooks $ + simpleUserHooks + { hookedPrograms = [bnfcProgram] + , postConf = \args flags packageDesc localBuildInfo -> do + let + addLicense :: FilePath -> IO () + addLicense file = do + let targetFile = "src/Language/EO/Phi/Syntax/" <> file + license <- readFile' "LICENSE" + let licenseFormatted = [fmt|{{-\n{license}-}}\n\n|] :: Text + code <- readFile' targetFile + writeFile' targetFile (licenseFormatted <> code) + + -- See the details on the command form in https://github.com/objectionary/eo-phi-normalizer/issues/347#issuecomment-2117097070 + command = + intercalate "; " $ + [ "set -ex" + , "bnfc --haskell -d -p Language.EO.Phi --generic -o src/ grammar/EO/Phi/Syntax.cf" + , "cd src/Language/EO/Phi/Syntax" + , "alex Lex.x" + , "happy Par.y" + , "true" + ] + + fullCommand = [fmt|bash -c ' {command} '|] + + putStrLn fullCommand + + _ <- callCommand fullCommand + _ <- addLicense "Abs.hs" + _ <- addLicense "Print.hs" + + postConf simpleUserHooks args flags packageDesc localBuildInfo + } -- | NOTE: This should be in Cabal.Distribution.Simple.Program.Builtin. bnfcProgram :: Program From 0fae402429f9a855ed8c28353e0bd0ccac159ace Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 3 Dec 2024 22:52:53 +0300 Subject: [PATCH 09/20] fix(ci): let check formatting in Setup.hs --- .github/workflows/ghc.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index 42eee0293..6f35699f0 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -55,7 +55,6 @@ jobs: pattern: | eo-phi-normalizer/**/*.hs !${{ env.syntax-dir }}/**/*.hs - !eo-phi-normalizer/Setup.hs - uses: haskell-actions/hlint-setup@v2 From 20d64a00b68ccc31fecaa045876625d0f37dd696 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Tue, 3 Dec 2024 22:53:09 +0300 Subject: [PATCH 10/20] fix(pre-commit): let check formatting in Setup.hs --- .pre-commit-config.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 11ed4b22a..40dc8acd6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,5 +25,4 @@ repos: exclude: | (?x)^( eo-phi-normalizer/src/Language/EO/Phi/Syntax/| - eo-phi-normalizer/Setup.hs - ) \ No newline at end of file + ) From fba4c2267dddb5302ce38180e4d6e3372e819f46 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 4 Dec 2024 20:59:37 +0300 Subject: [PATCH 11/20] refactor(eo-phi-normalizer): use throwIO instead of throw --- eo-phi-normalizer/app/Main.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/eo-phi-normalizer/app/Main.hs b/eo-phi-normalizer/app/Main.hs index 5b9a2efad..66815f044 100644 --- a/eo-phi-normalizer/app/Main.hs +++ b/eo-phi-normalizer/app/Main.hs @@ -51,7 +51,7 @@ module Main (main) where -import Control.Exception (Exception (..), SomeException, catch, throw) +import Control.Exception (Exception (..), SomeException, catch, throwIO) import Control.Lens.Lens ((&)) import Control.Lens.Operators ((?~)) import Control.Monad (forM, unless, when) @@ -466,14 +466,14 @@ getFile = \case Just file' -> doesFileExist file' >>= \case True -> pure (Just file') - False -> throw $ FileDoesNotExist file' + False -> throwIO $ FileDoesNotExist file' getProgram :: Maybe FilePath -> IO Program getProgram inputFile = do inputFile' <- getFile inputFile - src <- maybe getContents' readFile inputFile' `catch` (throw . CouldNotRead . show @SomeException) + src <- maybe getContents' readFile inputFile' `catch` (throwIO . CouldNotRead . show @SomeException) case parseProgram src of - Left err -> throw $ CouldNotParse err + Left err -> throwIO $ CouldNotParse err Right program -> pure program getLoggers :: Maybe FilePath -> IO (String -> IO (), String -> IO ()) @@ -510,7 +510,7 @@ getMetrics' program bindingsPath = do getMetrics :: Maybe String -> Maybe FilePath -> IO ProgramMetrics getMetrics bindingsPath inputFile = do program <- getProgram inputFile - either throw pure (getMetrics' program bindingsPath) + either throwIO pure (getMetrics' program bindingsPath) injectLamdbaPackage :: [Binding] -> [Binding] injectLamdbaPackage bs @@ -596,7 +596,7 @@ main = (withCP65001 . withUtf8) do return (False, ruleSet.title, convertRuleNamed <$> ruleSet.rules) unless (single || json || (chain && latex)) $ logStrLn ruleSetTitle bindingsWithDeps <- case deepMergePrograms (program' : deps) of - Left err -> throw (CouldNotMergeDependencies err) + Left err -> throwIO (CouldNotMergeDependencies err) Right (Program bindingsWithDeps) -> return bindingsWithDeps let Program bindings = program' uniqueResults @@ -608,7 +608,7 @@ main = (withCP65001 . withUtf8) do limits = ApplicationLimits maxDepth (maxGrowthFactor * objectSize (Formation bindings)) ctx = (defaultContext rules (Formation bindingsWithDeps)){builtinRules = builtin} -- IMPORTANT: context contains dependencies! totalResults = length uniqueResults - when (null uniqueResults || null (head uniqueResults)) (throw CouldNotNormalize) + when (null uniqueResults || null (head uniqueResults)) (throwIO CouldNotNormalize) if | single && json -> logStrLn @@ -663,7 +663,7 @@ main = (withCP65001 . withUtf8) do program' <- getProgram inputFile deps <- mapM (getProgram . Just) dependencies bindingsWithDeps <- case deepMergePrograms (program' : deps) of - Left err -> throw (CouldNotMergeDependencies err) + Left err -> throwIO (CouldNotMergeDependencies err) Right (Program bindingsWithDeps) -> return bindingsWithDeps (builtin, _ruleSetTitle, rules) <- case rulesPath of From 8cb4d08e9fa7a35dde5ec71cb35feeab6acb7188 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 4 Dec 2024 21:02:12 +0300 Subject: [PATCH 12/20] fix(eo-phi-normalizer): display errors with a correct locale set --- eo-phi-normalizer/Setup.hs | 16 +++++++++++++--- eo-phi-normalizer/app/Main.hs | 15 +++++++++++++-- eo-phi-normalizer/eo-phi-normalizer.cabal | 3 ++- eo-phi-normalizer/package.yaml | 1 + 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/eo-phi-normalizer/Setup.hs b/eo-phi-normalizer/Setup.hs index 63712bcfc..69c89b45f 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 (evaluate) +import Control.Exception (SomeException, catch, displayException, evaluate) import Data.ByteString as BS (readFile, writeFile) import Data.List (intercalate) import Data.Text (Text) @@ -41,7 +41,7 @@ import Distribution.Simple (defaultMainWithHooks, hookedPrograms, postConf, preB import Distribution.Simple.Program (Program (..), findProgramVersion, simpleProgram) import Main.Utf8 (withUtf8) import PyF (fmt) -import System.Exit (ExitCode (..)) +import System.Exit (ExitCode (..), exitWith) import System.IO.CodePage (withCP65001) import System.Process (callCommand) @@ -51,12 +51,22 @@ readFile' = (decodeUtf8 <$>) . BS.readFile writeFile' :: FilePath -> Text -> IO () writeFile' path = BS.writeFile path . encodeUtf8 +withCorrectLocale :: IO a -> IO a +withCorrectLocale act = do + let withCorrectLocale' = withCP65001 . Main.Utf8.withUtf8 + withCorrectLocale' act + `catch` ( \(x :: SomeException) -> + withCorrectLocale' do + putStrLn (displayException x) + exitWith (ExitFailure 1) + ) + -- | Run BNFC, happy, and alex on the grammar before the actual build step. -- -- All options for bnfc are hard-coded here. main :: IO () main = - withCP65001 . withUtf8 $ + withCorrectLocale $ defaultMainWithHooks $ simpleUserHooks { hookedPrograms = [bnfcProgram] diff --git a/eo-phi-normalizer/app/Main.hs b/eo-phi-normalizer/app/Main.hs index 66815f044..4c49185fb 100644 --- a/eo-phi-normalizer/app/Main.hs +++ b/eo-phi-normalizer/app/Main.hs @@ -51,7 +51,7 @@ module Main (main) where -import Control.Exception (Exception (..), SomeException, catch, throwIO) +import Control.Exception (Exception (..), SomeException, catch, throwIO, displayException) import Control.Lens.Lens ((&)) import Control.Lens.Operators ((?~)) import Control.Monad (forM, unless, when) @@ -89,6 +89,7 @@ import Options.Applicative qualified as Optparse (metavar) import Paths_eo_phi_normalizer (version) import PyF (fmt, fmtTrim) import System.Directory (createDirectoryIfMissing, doesFileExist) +import System.Exit (ExitCode (ExitFailure), exitWith) import System.FilePath (takeDirectory) import System.IO (IOMode (WriteMode), getContents', hFlush, hPutStr, hPutStrLn, openFile, stdout) import System.IO.CodePage (withCP65001) @@ -560,10 +561,20 @@ wrapRawBytesIn = \case obj@MetaTailContext{} -> obj obj@MetaFunction{} -> obj +withCorrectLocale :: IO a -> IO a +withCorrectLocale act = do + let withCorrectLocale' = withCP65001 . Main.Utf8.withUtf8 + withCorrectLocale' act + `catch` ( \(x :: SomeException) -> + withCorrectLocale' do + putStrLn (displayException x) + exitWith (ExitFailure 1) + ) + -- * Main main :: IO () -main = (withCP65001 . withUtf8) do +main = withCorrectLocale do opts <- customExecParser pprefs (cliOpts (showVersion version)) let printAsProgramOrAsObject = \case Formation bindings' -> printTree $ Program bindings' diff --git a/eo-phi-normalizer/eo-phi-normalizer.cabal b/eo-phi-normalizer/eo-phi-normalizer.cabal index ff41d522c..15260363a 100644 --- a/eo-phi-normalizer/eo-phi-normalizer.cabal +++ b/eo-phi-normalizer/eo-phi-normalizer.cabal @@ -204,7 +204,6 @@ custom-setup , base >=4.11.0.0 && <5.0 , bytestring , code-page - , extra , process >=1.6.3.0 , text , with-utf8 @@ -276,6 +275,7 @@ library , template-haskell , text , unordered-containers + , with-utf8 , yaml default-language: Haskell2010 @@ -396,6 +396,7 @@ test-suite doctests , template-haskell , text , unordered-containers + , with-utf8 , yaml default-language: Haskell2010 diff --git a/eo-phi-normalizer/package.yaml b/eo-phi-normalizer/package.yaml index fa150bbb9..082775e08 100644 --- a/eo-phi-normalizer/package.yaml +++ b/eo-phi-normalizer/package.yaml @@ -91,6 +91,7 @@ dependencies: - unordered-containers - containers - code-page + - with-utf8 default-extensions: - ImportQualifiedPost From aeda68ae60bbcb9a70d260e4e43ae735d764e2d0 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 4 Dec 2024 21:10:47 +0300 Subject: [PATCH 13/20] refactor(eo-phi-normalizer): fix formatting --- eo-phi-normalizer/app/Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-phi-normalizer/app/Main.hs b/eo-phi-normalizer/app/Main.hs index 4c49185fb..eff082b3d 100644 --- a/eo-phi-normalizer/app/Main.hs +++ b/eo-phi-normalizer/app/Main.hs @@ -51,7 +51,7 @@ module Main (main) where -import Control.Exception (Exception (..), SomeException, catch, throwIO, displayException) +import Control.Exception (Exception (..), SomeException, catch, displayException, throwIO) import Control.Lens.Lens ((&)) import Control.Lens.Operators ((?~)) import Control.Monad (forM, unless, when) From 6fffd52ed960314a315f74cbcbc6a0950b1380b9 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 4 Dec 2024 21:28:22 +0300 Subject: [PATCH 14/20] fix(eo-phi-normalizer): use throwIO instead of throw --- eo-phi-normalizer/app/Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-phi-normalizer/app/Main.hs b/eo-phi-normalizer/app/Main.hs index 1f003c24d..be7333b1b 100644 --- a/eo-phi-normalizer/app/Main.hs +++ b/eo-phi-normalizer/app/Main.hs @@ -641,7 +641,7 @@ main = withCorrectLocale do logStrLn "\\begin{phiquation*}" logStrLn [fmtTrim|{phiExpr}|] logStrLn "\\end{phiquation*}" - when (null uniqueResults || null (head uniqueResults)) (throw CouldNotNormalize) + when (null uniqueResults || null (head uniqueResults)) (throwIO CouldNotNormalize) if | single && json -> logStrLn From f7522c99a70a17c9543cc7d2793ab13ce3645b8f Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 4 Dec 2024 21:30:26 +0300 Subject: [PATCH 15/20] fix(eo-phi-normalizer): apply hlint suggestions --- eo-phi-normalizer/Setup.hs | 3 ++- eo-phi-normalizer/src/Language/EO/Phi/ToLaTeX.hs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eo-phi-normalizer/Setup.hs b/eo-phi-normalizer/Setup.hs index 69c89b45f..127cffe93 100644 --- a/eo-phi-normalizer/Setup.hs +++ b/eo-phi-normalizer/Setup.hs @@ -82,7 +82,8 @@ main = -- See the details on the command form in https://github.com/objectionary/eo-phi-normalizer/issues/347#issuecomment-2117097070 command = - intercalate "; " $ + intercalate + "; " [ "set -ex" , "bnfc --haskell -d -p Language.EO.Phi --generic -o src/ grammar/EO/Phi/Syntax.cf" , "cd src/Language/EO/Phi/Syntax" diff --git a/eo-phi-normalizer/src/Language/EO/Phi/ToLaTeX.hs b/eo-phi-normalizer/src/Language/EO/Phi/ToLaTeX.hs index c6f45d557..254304eb5 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/ToLaTeX.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/ToLaTeX.hs @@ -108,7 +108,7 @@ inMathMode = (" $ " <>) . (<> " $ ") instance ToLatex RuleContext where toLatex RuleContext{..} = maybe mempty (\x -> inMathMode $ toLatex GlobalObject <> " -> " <> toLatex x) global_object - <> maybe mempty (\x -> (inMathMode $ toLatex x) <> " is the scope of the redex") current_object + <> maybe mempty (\x -> inMathMode (toLatex x) <> " is the scope of the redex") current_object <> maybe mempty (\x -> toLatex x <> " is the current attribute") current_attribute instance ToLatex RuleAttribute where From 30b6b47348be67256eb71150894ebc871790fd5d Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 4 Dec 2024 23:14:32 +0300 Subject: [PATCH 16/20] refactor(eo-phi-normalizer): move withCorrectLocale to the library --- eo-phi-normalizer/app/Main.hs | 16 ++-------------- eo-phi-normalizer/eo-phi-normalizer.cabal | 1 + eo-phi-normalizer/package.yaml | 1 - eo-phi-normalizer/src/Language/EO/Locale.hs | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 eo-phi-normalizer/src/Language/EO/Locale.hs diff --git a/eo-phi-normalizer/app/Main.hs b/eo-phi-normalizer/app/Main.hs index be7333b1b..e575c33ac 100644 --- a/eo-phi-normalizer/app/Main.hs +++ b/eo-phi-normalizer/app/Main.hs @@ -51,7 +51,7 @@ module Main (main) where -import Control.Exception (Exception (..), SomeException, catch, displayException, throwIO) +import Control.Exception (Exception (..), SomeException, catch, throwIO) import Control.Lens.Lens ((&)) import Control.Lens.Operators ((?~)) import Control.Monad (forM, unless, when) @@ -67,6 +67,7 @@ import Data.Text.Lazy.Manipulate (toOrdinal) import Data.Version (showVersion) import Data.Yaml (decodeFileThrow, decodeThrow) import GHC.Generics (Generic) +import Language.EO.Locale (withCorrectLocale) import Language.EO.Phi (Binding (..), Bytes (Bytes), Object (..), Program (Program), parseProgram, printTree) import Language.EO.Phi.Dataize import Language.EO.Phi.Dataize.Context @@ -84,16 +85,13 @@ import Language.EO.Phi.Rules.RunYegor (yegorRuleSet) import Language.EO.Phi.Rules.Yaml (RuleSet (rules, title), convertRuleNamed, parseRuleSetFromFile) import Language.EO.Phi.ToLaTeX import Language.EO.Test.YamlSpec (spec) -import Main.Utf8 (withUtf8) import Options.Applicative hiding (metavar) import Options.Applicative qualified as Optparse (metavar) import Paths_eo_phi_normalizer (version) import PyF (fmt, fmtTrim) import System.Directory (createDirectoryIfMissing, doesFileExist) -import System.Exit (ExitCode (ExitFailure), exitWith) import System.FilePath (takeDirectory) import System.IO (IOMode (WriteMode), getContents', hFlush, hPutStr, hPutStrLn, openFile, stdout) -import System.IO.CodePage (withCP65001) import Test.Hspec.Core.Runner data CLI'RewritePhi = CLI'RewritePhi @@ -566,16 +564,6 @@ wrapRawBytesIn = \case obj@MetaTailContext{} -> obj obj@MetaFunction{} -> obj -withCorrectLocale :: IO a -> IO a -withCorrectLocale act = do - let withCorrectLocale' = withCP65001 . Main.Utf8.withUtf8 - withCorrectLocale' act - `catch` ( \(x :: SomeException) -> - withCorrectLocale' do - putStrLn (displayException x) - exitWith (ExitFailure 1) - ) - -- * Main main :: IO () diff --git a/eo-phi-normalizer/eo-phi-normalizer.cabal b/eo-phi-normalizer/eo-phi-normalizer.cabal index 957f1de23..7334c1a84 100644 --- a/eo-phi-normalizer/eo-phi-normalizer.cabal +++ b/eo-phi-normalizer/eo-phi-normalizer.cabal @@ -210,6 +210,7 @@ custom-setup library exposed-modules: + Language.EO.Locale Language.EO.Phi Language.EO.Phi.Dataize Language.EO.Phi.Dataize.Atoms diff --git a/eo-phi-normalizer/package.yaml b/eo-phi-normalizer/package.yaml index ffa7fb2da..bfe18bc97 100644 --- a/eo-phi-normalizer/package.yaml +++ b/eo-phi-normalizer/package.yaml @@ -129,7 +129,6 @@ executables: - -rtsopts - -with-rtsopts=-N dependencies: - - with-utf8 - eo-phi-normalizer - optparse-applicative - aeson-pretty diff --git a/eo-phi-normalizer/src/Language/EO/Locale.hs b/eo-phi-normalizer/src/Language/EO/Locale.hs new file mode 100644 index 000000000..8e6110749 --- /dev/null +++ b/eo-phi-normalizer/src/Language/EO/Locale.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module Language.EO.Locale where + +import Control.Exception (Exception (..), SomeException, catch) +import Main.Utf8 (withUtf8) +import System.Exit (ExitCode (..), exitWith) +import System.IO.CodePage (withCP65001) + +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) + ) From 6dbd8e738406172f88e8221611d3aa779fef5b32 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 4 Dec 2024 23:15:01 +0300 Subject: [PATCH 17/20] feat(eo-phi-normalizer): use withCorrectLocale in tests --- eo-phi-normalizer/eo-phi-normalizer.cabal | 1 + eo-phi-normalizer/package.yaml | 1 - eo-phi-normalizer/test/Main.hs | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eo-phi-normalizer/eo-phi-normalizer.cabal b/eo-phi-normalizer/eo-phi-normalizer.cabal index 7334c1a84..943255baf 100644 --- a/eo-phi-normalizer/eo-phi-normalizer.cabal +++ b/eo-phi-normalizer/eo-phi-normalizer.cabal @@ -332,6 +332,7 @@ test-suite doctests type: exitcode-stdio-1.0 main-is: Main.hs other-modules: + Language.EO.Locale Language.EO.Phi Language.EO.Phi.Dataize Language.EO.Phi.Dataize.Atoms diff --git a/eo-phi-normalizer/package.yaml b/eo-phi-normalizer/package.yaml index bfe18bc97..10b1dee07 100644 --- a/eo-phi-normalizer/package.yaml +++ b/eo-phi-normalizer/package.yaml @@ -143,7 +143,6 @@ tests: - -with-rtsopts=-N dependencies: - eo-phi-normalizer - - with-utf8 - hspec - hspec-discover - QuickCheck diff --git a/eo-phi-normalizer/test/Main.hs b/eo-phi-normalizer/test/Main.hs index cec86ad6b..8a7d3f2bd 100644 --- a/eo-phi-normalizer/test/Main.hs +++ b/eo-phi-normalizer/test/Main.hs @@ -23,9 +23,9 @@ {- FOURMOLU_ENABLE -} module Main where -import Main.Utf8 import Spec qualified import Test.Hspec.Runner +import Language.EO.Locale (withCorrectLocale) main :: IO () -main = withUtf8 $ hspecWith defaultConfig Spec.spec +main = withCorrectLocale $ hspecWith defaultConfig Spec.spec From 0c01ef28b502eecf9fd94a122c13d02ef73a01e2 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 4 Dec 2024 23:15:29 +0300 Subject: [PATCH 18/20] try(ci): don't set codepage on Windows --- .github/workflows/ghc.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/ghc.yml b/.github/workflows/ghc.yml index 6f35699f0..9b8b86911 100644 --- a/.github/workflows/ghc.yml +++ b/.github/workflows/ghc.yml @@ -104,10 +104,6 @@ jobs: submodules: true ref: ${{ github.ref }} - - name: Set codepage on Windows - if: ${{ runner.os == 'Windows' }} - run: chcp 65001 - - name: Restore Syntax files id: restore-syntax-files uses: actions/cache/restore@v4 @@ -162,10 +158,6 @@ jobs: submodules: true ref: ${{ github.ref }} - - name: Set codepage on Windows - if: ${{ runner.os == 'Windows' }} - run: chcp 65001 - - name: Restore Syntax files id: restore-syntax-files uses: actions/cache/restore@v4 From 63d9b8d2d1e0b54d08a790f56b8221b3c4c40278 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 4 Dec 2024 23:16:21 +0300 Subject: [PATCH 19/20] fix(eo-phi-normalizer): formatting --- eo-phi-normalizer/test/Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-phi-normalizer/test/Main.hs b/eo-phi-normalizer/test/Main.hs index 8a7d3f2bd..ab33535a0 100644 --- a/eo-phi-normalizer/test/Main.hs +++ b/eo-phi-normalizer/test/Main.hs @@ -23,9 +23,9 @@ {- FOURMOLU_ENABLE -} module Main where +import Language.EO.Locale (withCorrectLocale) import Spec qualified import Test.Hspec.Runner -import Language.EO.Locale (withCorrectLocale) main :: IO () main = withCorrectLocale $ hspecWith defaultConfig Spec.spec From 6c09e3c26d39ea287ef418e569dcd91dfe8aaba5 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Wed, 4 Dec 2024 23:17:52 +0300 Subject: [PATCH 20/20] fix(eo-phi-normalizer): add license --- eo-phi-normalizer/src/Language/EO/Locale.hs | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/eo-phi-normalizer/src/Language/EO/Locale.hs b/eo-phi-normalizer/src/Language/EO/Locale.hs index 8e6110749..f6e5717e2 100644 --- a/eo-phi-normalizer/src/Language/EO/Locale.hs +++ b/eo-phi-normalizer/src/Language/EO/Locale.hs @@ -1,3 +1,26 @@ +{- FOURMOLU_DISABLE -} +-- The MIT License (MIT) + +-- Copyright (c) 2016-2024 Objectionary.com + +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: + +-- The above copyright notice and this permission notice shall be included +-- in all copies or substantial portions of the Software. + +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +-- SOFTWARE. +{- FOURMOLU_ENABLE -} {-# LANGUAGE BlockArguments #-} {-# LANGUAGE ScopedTypeVariables #-}