From 11677cc25491312344a32aa3113f808387d55ced Mon Sep 17 00:00:00 2001 From: "Harley D. Eades III" Date: Wed, 1 Apr 2026 16:36:16 -0400 Subject: [PATCH 1/3] Error message should reference "grc" rather than "gr". --- compiler/app/Language/Granule/Compiler.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/app/Language/Granule/Compiler.hs b/compiler/app/Language/Granule/Compiler.hs index c5f2c0ff..27b9cfe8 100644 --- a/compiler/app/Language/Granule/Compiler.hs +++ b/compiler/app/Language/Granule/Compiler.hs @@ -166,7 +166,7 @@ getGrConfig = do Right Nothing -> do printInfo . red . unlines $ [ "Couldn't parse granule configuration file at " <> configFile - , "Run `gr --help` to see a list of accepted flags." + , "Run `grc --help` to see a list of accepted flags." ] pure mempty Right (Just config) -> pure config From b359190840f07000eece7528d153c74a9a36c585 Mon Sep 17 00:00:00 2001 From: "Harley D. Eades III" Date: Wed, 1 Apr 2026 17:58:15 -0400 Subject: [PATCH 2/3] Added the "--dest PATH" flag. PATH is the location where all generated Haskell files will be written to. These changes preserve the original behavior in that if "--dest" is not specified then the original behavior is used. Thus, this is completely backward compatible. --- compiler/app/Language/Granule/Compiler.hs | 31 ++++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/compiler/app/Language/Granule/Compiler.hs b/compiler/app/Language/Granule/Compiler.hs index 27b9cfe8..4f8d3743 100644 --- a/compiler/app/Language/Granule/Compiler.hs +++ b/compiler/app/Language/Granule/Compiler.hs @@ -9,12 +9,12 @@ import Control.Exception (SomeException, displayException, try) import Control.Monad ((<=<), forM_, when) import Development.GitRev import Data.Char (isSpace) -import Data.List (isPrefixOf, stripPrefix) +import Data.List (stripPrefix) import Data.Maybe (fromMaybe) import Data.Version (showVersion) import System.Directory (getAppUserDataDirectory, getCurrentDirectory) -import System.FilePath (takeFileName) +import System.FilePath ((), splitFileName) import "Glob" System.FilePath.Glob (glob) import Options.Applicative import qualified Options.Applicative.Help.Pretty as OA @@ -42,20 +42,23 @@ compileGrOnFiles globPatterns config = let ?globals = grGlobals config in do pwd <- getCurrentDirectory forM_ globPatterns $ \pat -> do paths <- glob pat + debugM "Glob paths: " $ show paths case paths of [] -> error "No matching files" - _ -> forM_ paths $ \path -> do - let fileName = if pwd `isPrefixOf` path then takeFileName path else path + _ -> forM_ paths $ \inPath -> do + let (cwd, fileName) = splitFileName inPath let ?globals = ?globals{ globalsSourceFilePath = Just fileName } in do printInfo $ "Checking " <> fileName <> "..." src <- preprocess (rewriter config) (keepBackup config) - path + inPath (literateEnvName config) hsCode <- compile config src - debugM "Code: " hsCode - let outPath = changeFileExtension path + debugM "Code: " hsCode + let destPath = fromMaybe cwd $ grWriteDest config + debugM "destPath: " destPath + let outPath = changeFileExtension $ destPath fileName printSuccess $ "Writing " ++ outPath writeFile outPath hsCode @@ -115,6 +118,7 @@ data GrConfig = GrConfig , grLiterateEnvName :: Maybe String , grShowVersion :: Bool , grGlobals :: Globals + , grWriteDest :: Maybe FilePath } rewriter :: GrConfig -> Maybe Rewriter @@ -133,15 +137,17 @@ instance Semigroup GrConfig where , grLiterateEnvName = grLiterateEnvName c1 <|> grLiterateEnvName c2 , grGlobals = grGlobals c1 <> grGlobals c2 , grShowVersion = grShowVersion c1 || grShowVersion c2 + , grWriteDest = grWriteDest c1 <|> grWriteDest c2 } instance Monoid GrConfig where mempty = GrConfig - { grRewriter = Nothing + { grRewriter = Nothing , grKeepBackup = Nothing , grLiterateEnvName = Nothing , grGlobals = mempty , grShowVersion = False + , grWriteDest = Nothing } getGrConfig :: IO ([FilePath], GrConfig) @@ -272,7 +278,7 @@ parseGrConfig = info (go <**> helper) $ briefDesc globalsIncludePath <- optional $ strOption - $ long "include-path" + $ long "include-inPath" <> help ("Path to the standard library. Defaults to " <> show includePath) <> metavar "PATH" @@ -358,6 +364,12 @@ parseGrConfig = info (go <**> helper) $ briefDesc flag Nothing (Just True) $ long "raw-data" <> help "Show raw data of benchmarking data for synthesis." + + grWriteDest <- + optional $ strOption + $ long "dest" + <> help "Path to the location to write generated Haskell files." + <> metavar "PATH" pure ( globPatterns @@ -395,6 +407,7 @@ parseGrConfig = info (go <**> helper) $ briefDesc , globalsExtensions = [] , globalsDocMode = Nothing } + , grWriteDest } ) where From 366b69f9155802d684c4fb7035517e3a0e2ca89a Mon Sep 17 00:00:00 2001 From: "Harley D. Eades III" Date: Wed, 1 Apr 2026 18:31:18 -0400 Subject: [PATCH 3/3] Fixing an accidental change. --- compiler/app/Language/Granule/Compiler.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/app/Language/Granule/Compiler.hs b/compiler/app/Language/Granule/Compiler.hs index 4f8d3743..e868cded 100644 --- a/compiler/app/Language/Granule/Compiler.hs +++ b/compiler/app/Language/Granule/Compiler.hs @@ -278,7 +278,7 @@ parseGrConfig = info (go <**> helper) $ briefDesc globalsIncludePath <- optional $ strOption - $ long "include-inPath" + $ long "include-path" <> help ("Path to the standard library. Defaults to " <> show includePath) <> metavar "PATH"