Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Aug 27, 2024
1 parent 2b76f5d commit 5341438
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions app/Commands/Isabelle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ runCommand opts = do
let inputFile = opts ^. isabelleInputFile
res <- runPipeline opts inputFile upToIsabelle
let thy = res ^. resultTheory
comments = res ^. resultComments
outputDir <- fromAppPathDir (opts ^. isabelleOutputDir)
if
| opts ^. isabelleStdout -> do
renderStdOut (ppOutDefault thy)
renderStdOut (ppOutDefault comments thy)
putStrLn ""
| otherwise -> do
ensureDir outputDir
Expand All @@ -29,4 +30,4 @@ runCommand opts = do
)
absPath :: Path Abs File
absPath = outputDir <//> file
writeFileEnsureLn absPath (ppPrint thy <> "\n")
writeFileEnsureLn absPath (ppPrint comments thy <> "\n")
8 changes: 4 additions & 4 deletions src/Juvix/Compiler/Backend/Isabelle/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import Juvix.Data.PPOutput
import Juvix.Prelude
import Prettyprinter.Render.Terminal qualified as Ansi

ppOutDefault :: (PrettyCode c) => c -> AnsiText
ppOutDefault = mkAnsiText . PPOutput . doc defaultOptions
ppOutDefault :: (PrettyCode c) => [Comment] -> c -> AnsiText
ppOutDefault comments = mkAnsiText . PPOutput . doc (defaultOptions comments)

ppOut :: (CanonicalProjection a Options, PrettyCode c) => a -> c -> AnsiText
ppOut o = mkAnsiText . PPOutput . doc (project o)
Expand All @@ -18,5 +18,5 @@ ppTrace' opts = Ansi.renderStrict . reAnnotateS stylize . layoutPretty defaultLa
ppTrace :: (PrettyCode c) => c -> Text
ppTrace = ppTrace' traceOptions

ppPrint :: (PrettyCode c) => c -> Text
ppPrint = show . ppOutDefault
ppPrint :: (PrettyCode c) => [Comment] -> c -> Text
ppPrint comments = show . ppOutDefault comments
8 changes: 5 additions & 3 deletions src/Juvix/Compiler/Backend/Isabelle/Pretty/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ module Juvix.Compiler.Backend.Isabelle.Pretty.Options where
import Juvix.Prelude

data Options = Options
{ _optComments :: [Comment]
}

makeLenses ''Options

defaultOptions :: Options
defaultOptions :: [Comment] -> Options
defaultOptions = Options

traceOptions :: Options
traceOptions = defaultOptions
traceOptions = defaultOptions []

fromGenericOptions :: GenericOptions -> Options
fromGenericOptions _ = defaultOptions
fromGenericOptions _ = defaultOptions []

instance CanonicalProjection GenericOptions Options where
project = fromGenericOptions

0 comments on commit 5341438

Please sign in to comment.