Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FileExt type #2467

Merged
merged 9 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Commands/Compile/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ parseMainCompileOptions :: Parser CompileOptions
parseMainCompileOptions =
parseCompileOptions
supportedTargets
parseInputJuvixFile
(parseInputFile FileExtJuvix)
2 changes: 1 addition & 1 deletion app/Commands/Dev/Asm/Compile/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ parseAsmCompileOptions :: Parser AsmCompileOptions
parseAsmCompileOptions =
parseCompileOptions
asmSupportedTargets
parseInputJuvixAsmFile
(parseInputFile FileExtJuvixAsm)
2 changes: 1 addition & 1 deletion app/Commands/Dev/Asm/Run/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ parseAsmRunOptions = do
( long "no-validate"
<> help "Don't validate the input before running"
)
_asmRunInputFile <- parseInputJuvixAsmFile
_asmRunInputFile <- parseInputFile FileExtJuvixAsm
pure AsmRunOptions {..}
2 changes: 1 addition & 1 deletion app/Commands/Dev/Asm/Validate/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ makeLenses ''AsmValidateOptions

parseAsmValidateOptions :: Parser AsmValidateOptions
parseAsmValidateOptions = do
_asmValidateInputFile <- parseInputJuvixAsmFile
_asmValidateInputFile <- parseInputFile FileExtJuvixAsm
_asmValidateNoPrint <-
switch
( long "no-print"
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/Dev/Core/Asm/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ parseCoreAsmOptions = do
( long "print"
<> help "print the generated JuvixAsm code instead of running it"
)
_coreAsmInputFile <- parseInputJuvixCoreFile
_coreAsmInputFile <- parseInputFile FileExtJuvixCore
pure CoreAsmOptions {..}
2 changes: 1 addition & 1 deletion app/Commands/Dev/Core/Compile/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ parseCoreCompileOptions :: Parser CoreCompileOptions
parseCoreCompileOptions =
parseCompileOptions
coreSupportedTargets
parseInputJuvixAsmFile
(parseInputFile FileExtJuvixAsm)
2 changes: 1 addition & 1 deletion app/Commands/Dev/Core/Eval/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ parseCoreEvalOptions = do
_coreEvalShowIdentIds <- optIdentIds
_coreEvalShowArgsNum <- optArgsNum
_coreEvalNoDisambiguate <- optNoDisambiguate
_coreEvalInputFile <- parseInputJuvixCoreFile
_coreEvalInputFile <- parseInputFile FileExtJuvixCore
pure CoreEvalOptions {..}
2 changes: 1 addition & 1 deletion app/Commands/Dev/Core/FromConcrete/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ parseCoreFromConcreteOptions = do
( long "no-io"
<> help "Don't interpret the IO effects"
)
_coreFromConcreteInputFile <- parseInputJuvixFile
_coreFromConcreteInputFile <- parseInputFile FileExtJuvixCore
_coreFromConcreteSymbolName <-
optional $
strOption
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/Dev/Core/Normalize/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ parseCoreNormalizeOptions = do
_coreNormalizeShowIdentIds <- optIdentIds
_coreNormalizeShowArgsNum <- optArgsNum
_coreNormalizeNoDisambiguate <- optNoDisambiguate
_coreNormalizeInputFile <- parseInputJuvixCoreFile
_coreNormalizeInputFile <- parseInputFile FileExtJuvixCore
pure CoreNormalizeOptions {..}
2 changes: 1 addition & 1 deletion app/Commands/Dev/Core/Read/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ parseCoreReadOptions = do
<> help "normalize after the transformation"
)
_coreReadTransformations <- optTransformationIds
_coreReadInputFile <- parseInputJuvixCoreFile
_coreReadInputFile <- parseInputFile FileExtJuvixCore
pure CoreReadOptions {..}
2 changes: 1 addition & 1 deletion app/Commands/Dev/Core/Strip/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ parseCoreStripOptions = do
( long "no-print"
<> help "do not print the stripped code"
)
_coreStripInputFile <- parseInputJuvixCoreFile
_coreStripInputFile <- parseInputFile FileExtJuvixCore
pure CoreStripOptions {..}
2 changes: 1 addition & 1 deletion app/Commands/Dev/DisplayRoot/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ parseRoot = do
<> help "print the juvix.yaml file as parsed"
)

_rootMainFile <- optional parseInputJuvixFile
_rootMainFile <- optional (parseInputFile FileExtJuvix)
pure RootOptions {..}
4 changes: 3 additions & 1 deletion app/Commands/Dev/Geb/Eval/Options.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Commands.Dev.Geb.Eval.Options where

import CommonOptions
import Data.List.NonEmpty qualified as NonEmpty
import Juvix.Compiler.Backend.Geb.Evaluator qualified as Geb
import Juvix.Compiler.Backend.Geb.Pretty qualified as Geb

Expand All @@ -23,7 +24,8 @@ instance CanonicalProjection GebEvalOptions Geb.Options where

parseGebEvalOptions :: Parser GebEvalOptions
parseGebEvalOptions = do
_gebEvalOptionsInputFile <- parseInputJuvixGebFile
_gebEvalOptionsInputFile <-
parseInputFiles (NonEmpty.fromList [FileExtJuvixGeb, FileExtJuvix])
_gebEvalOptionsOutputMorphism <- optOutputMorphism
pure GebEvalOptions {..}

Expand Down
4 changes: 3 additions & 1 deletion app/Commands/Dev/Geb/Infer/Options.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Commands.Dev.Geb.Infer.Options where

import CommonOptions
import Data.List.NonEmpty qualified as NonEmpty
import Juvix.Compiler.Backend.Geb.Pretty qualified as Geb

newtype GebInferOptions = GebInferOptions
Expand All @@ -15,5 +16,6 @@ instance CanonicalProjection GebInferOptions Geb.Options where

parseGebInferOptions :: Parser GebInferOptions
parseGebInferOptions = do
_gebInferOptionsInputFile <- parseInputJuvixGebFile
_gebInferOptionsInputFile <-
(parseInputFiles (NonEmpty.fromList [FileExtJuvixGeb, FileExtJuvix]))
pure GebInferOptions {..}
4 changes: 3 additions & 1 deletion app/Commands/Dev/Geb/Read/Options.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Commands.Dev.Geb.Read.Options where

import CommonOptions
import Data.List.NonEmpty qualified as NonEmpty
import Juvix.Compiler.Backend.Geb.Pretty qualified as Geb

newtype GebReadOptions = GebReadOptions
Expand All @@ -15,5 +16,6 @@ instance CanonicalProjection GebReadOptions Geb.Options where

parseGebReadOptions :: Parser GebReadOptions
parseGebReadOptions = do
_gebReadOptionsInputFile <- parseInputJuvixGebFile
_gebReadOptionsInputFile <-
parseInputFiles (NonEmpty.fromList [FileExtJuvixGeb, FileExtJuvix])
pure GebReadOptions {..}
2 changes: 1 addition & 1 deletion app/Commands/Dev/Highlight/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ parseHighlight = do
<> completeWith (map show allBackends)
)

_highlightInputFile <- parseInputJuvixFile
_highlightInputFile <- parseInputFile FileExtJuvix
pure HighlightOptions {..}
where
allBackends :: [HighlightBackend]
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/Dev/Internal/Arity/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ makeLenses ''InternalArityOptions

parseInternalArity :: Parser InternalArityOptions
parseInternalArity = do
_internalArityInputFile <- parseInputJuvixFile
_internalArityInputFile <- parseInputFile FileExtJuvix
pure InternalArityOptions {..}
2 changes: 1 addition & 1 deletion app/Commands/Dev/Internal/Pretty/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ makeLenses ''InternalPrettyOptions

parseInternalPretty :: Parser InternalPrettyOptions
parseInternalPretty = do
_internalPrettyInputFile <- parseInputJuvixFile
_internalPrettyInputFile <- parseInputFile FileExtJuvix
pure InternalPrettyOptions {..}
2 changes: 1 addition & 1 deletion app/Commands/Dev/Internal/Reachability/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ makeLenses ''InternalReachabilityOptions

parseInternalReachability :: Parser InternalReachabilityOptions
parseInternalReachability = do
_internalReachabilityInputFile <- parseInputJuvixFile
_internalReachabilityInputFile <- parseInputFile FileExtJuvix
pure InternalReachabilityOptions {..}
2 changes: 1 addition & 1 deletion app/Commands/Dev/Internal/Typecheck/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ parseInternalType = do
( long "print-result"
<> help "Print the type checked module if successful"
)
_internalTypeInputFile <- parseInputJuvixFile
_internalTypeInputFile <- parseInputFile FileExtJuvix
pure InternalTypeOptions {..}
4 changes: 2 additions & 2 deletions app/Commands/Dev/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ runCommand :: (Members '[Embed IO, App] r) => ParseOptions -> Sem r ()
runCommand opts = do
m <-
head . (^. Parser.resultModules)
<$> runPipeline (opts ^. parseInputFile) upToParsing
if opts ^. parseNoPrettyShow then say (show m) else say (pack (ppShow m))
<$> runPipeline (opts ^. parseOptionsInputFile) upToParsing
if opts ^. parseOptionsNoPrettyShow then say (show m) else say (pack (ppShow m))
8 changes: 4 additions & 4 deletions app/Commands/Dev/Parse/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ module Commands.Dev.Parse.Options where
import CommonOptions

data ParseOptions = ParseOptions
{ _parseNoPrettyShow :: Bool,
_parseInputFile :: AppPath File
{ _parseOptionsNoPrettyShow :: Bool,
_parseOptionsInputFile :: AppPath File
}
deriving stock (Data)

makeLenses ''ParseOptions

parseParse :: Parser ParseOptions
parseParse = do
_parseNoPrettyShow <-
_parseOptionsNoPrettyShow <-
switch
( long "no-pretty-show"
<> help "Disable formatting of the Haskell AST"
)
_parseInputFile <- parseInputJuvixFile
_parseOptionsInputFile <- parseInputFile FileExtJuvix
pure ParseOptions {..}
2 changes: 1 addition & 1 deletion app/Commands/Dev/Repl/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ parseDevRepl :: Parser ReplOptions
parseDevRepl = do
let _replPrintValues = False
_replIsDev = True
_replInputFile <- optional parseInputJuvixFile
_replInputFile <- optional (parseInputFile FileExtJuvix)
_replTransformations <- do
ts <- optTransformationIds
pure $
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/Dev/Runtime/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ parseRuntimeOptions :: Parser CompileOptions
parseRuntimeOptions =
parseCompileOptions
runtimeSupportedTargets
parseInputJuvixFile
(parseInputFile FileExtJuvix)

parseRuntimeCommand :: Parser RuntimeCommand
parseRuntimeCommand =
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/Dev/Scope/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ parseScope = do
( long "list-comments"
<> help "List the user comments"
)
_scopeInputFile <- parseInputJuvixFile
_scopeInputFile <- parseInputFile FileExtJuvix
pure ScopeOptions {..}

instance CanonicalProjection (GlobalOptions, ScopeOptions) Scoper.Options where
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/Dev/Termination/CallGraph/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ parseCallGraph = do
<> short 'f'
<> help "Only shows the specified function"
)
_graphInputFile <- parseInputJuvixFile
_graphInputFile <- parseInputFile FileExtJuvix
pure CallGraphOptions {..}
2 changes: 1 addition & 1 deletion app/Commands/Dev/Termination/Calls/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ parseCalls = do
<> value Internal.ArgRel
<> help "possible values: argument, relation, both"
)
_callsInputFile <- parseInputJuvixFile
_callsInputFile <- parseInputFile FileExtJuvix
pure CallsOptions {..}
where
decrArgsParser :: ReadM Internal.ShowDecrArgs
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/Eval/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ instance CanonicalProjection EvalOptions Eval.EvalOptions where

parseEvalOptions :: Parser EvalOptions
parseEvalOptions = do
_evalInputFile <- parseInputJuvixFile
_evalInputFile <- parseInputFile FileExtJuvix
_evalSymbolName <-
optional $
strOption
Expand Down
4 changes: 2 additions & 2 deletions app/Commands/Extra/Compile/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ parseCompileOptions ::
SupportedTargets ->
Parser (AppPath File) ->
Parser CompileOptions
parseCompileOptions supportedTargets parseInputFile = do
parseCompileOptions supportedTargets parserFile = do
_compileDebug <-
switch
( short 'g'
Expand Down Expand Up @@ -110,7 +110,7 @@ parseCompileOptions supportedTargets parseInputFile = do
)
_compileTarget <- optCompileTarget supportedTargets
_compileOutputFile <- optional parseGenericOutputFile
_compileInputFile <- optional parseInputFile
_compileInputFile <- optional parserFile
pure CompileOptions {..}

optCompileTarget :: SupportedTargets -> Parser CompileTarget
Expand Down
4 changes: 2 additions & 2 deletions app/Commands/Format/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ parseInputJuvixFileOrDir :: Parser (Prepath FileOrDir)
parseInputJuvixFileOrDir =
strArgument
( metavar "JUVIX_FILE_OR_PROJECT"
<> help "Path to a .juvix file or to a directory containing a Juvix project."
<> completer juvixCompleter
<> help ("Path to a " <> show FileExtJuvix <> " file or to a directory containing a Juvix project.")
<> completer (extCompleter FileExtJuvix)
<> action "directory"
)

Expand Down
2 changes: 1 addition & 1 deletion app/Commands/Html/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ parseHtml = do
( long "open"
<> help "Open the documentation after generating it"
)
_htmlInputFile <- parseInputJuvixFile
_htmlInputFile <- parseInputFile FileExtJuvix
pure HtmlOptions {..}
where
allThemes :: [Theme]
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/Repl/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ parseRepl = do
_replNoDisambiguate = False
_replPrintValues = True
_replIsDev = False
_replInputFile <- optional parseInputJuvixFile
_replInputFile <- optional (parseInputFile FileExtJuvix)
_replNoPrelude <-
switch
( long "no-prelude"
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/Typecheck/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ makeLenses ''TypecheckOptions

parseTypecheck :: Parser TypecheckOptions
parseTypecheck = do
_typecheckInputFile <- parseInputJuvixFile
_typecheckInputFile <- parseInputFile FileExtJuvix
pure TypecheckOptions {..}

instance CanonicalProjection TypecheckOptions Internal.InternalTypeOptions where
Expand Down
Loading