1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-24 07:57:58 +03:00
juvix/app/Commands/Dev/Core/Eval/Options.hs
Jonathan Cubides 830b3be304
Add FileExt type (#2467)
This PR introduces FileExt type, and consequently, one can generalise
methods and matches based on the file extension; for example,
`parseInputJuvixAsmFile` is now an app. `parseInputFile FileExtJuvixAsm`
2023-10-25 12:02:12 +02:00

49 lines
1.4 KiB
Haskell

module Commands.Dev.Core.Eval.Options where
import CommonOptions
import Evaluator qualified as Eval
import Juvix.Compiler.Core.Pretty.Options qualified as Core
data CoreEvalOptions = CoreEvalOptions
{ _coreEvalNoIO :: Bool,
_coreEvalInputFile :: AppPath File,
_coreEvalShowDeBruijn :: Bool,
_coreEvalShowIdentIds :: Bool,
_coreEvalShowArgsNum :: Bool,
_coreEvalNoDisambiguate :: Bool
}
deriving stock (Data)
makeLenses ''CoreEvalOptions
instance CanonicalProjection CoreEvalOptions Core.Options where
project c =
Core.defaultOptions
{ Core._optShowDeBruijnIndices = c ^. coreEvalShowDeBruijn,
Core._optShowIdentIds = c ^. coreEvalShowIdentIds,
Core._optShowArgsNum = c ^. coreEvalShowArgsNum
}
instance CanonicalProjection CoreEvalOptions Eval.EvalOptions where
project c =
Eval.EvalOptions
{ _evalInputFile = c ^. coreEvalInputFile,
_evalNoIO = c ^. coreEvalNoIO,
_evalNoDisambiguate = c ^. coreEvalNoDisambiguate,
_evalPrintValues = False
}
parseCoreEvalOptions :: Parser CoreEvalOptions
parseCoreEvalOptions = do
_coreEvalNoIO <-
switch
( long "no-io"
<> help "Do not interpret the IO effects"
)
_coreEvalShowDeBruijn <- optDeBruijn
_coreEvalShowIdentIds <- optIdentIds
_coreEvalShowArgsNum <- optArgsNum
_coreEvalNoDisambiguate <- optNoDisambiguate
_coreEvalInputFile <- parseInputFile FileExtJuvixCore
pure CoreEvalOptions {..}