mirror of
https://github.com/anoma/juvix.git
synced 2024-12-20 21:31:48 +03:00
830b3be304
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`
49 lines
1.4 KiB
Haskell
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 {..}
|