2022-09-14 17:16:15 +03:00
|
|
|
module Commands.Dev.Core.Eval.Options where
|
|
|
|
|
|
|
|
import CommonOptions
|
2022-11-07 16:47:56 +03:00
|
|
|
import Evaluator qualified as Eval
|
2022-09-15 17:26:02 +03:00
|
|
|
import Juvix.Compiler.Core.Pretty.Options qualified as Core
|
2022-09-14 17:16:15 +03:00
|
|
|
|
|
|
|
data CoreEvalOptions = CoreEvalOptions
|
|
|
|
{ _coreEvalNoIO :: Bool,
|
2022-12-20 15:05:40 +03:00
|
|
|
_coreEvalInputFile :: AppPath File,
|
2023-03-15 18:41:39 +03:00
|
|
|
_coreEvalShowDeBruijn :: Bool,
|
|
|
|
_coreEvalShowIdentIds :: Bool,
|
2023-03-30 14:23:40 +03:00
|
|
|
_coreEvalShowArgsNum :: Bool,
|
2023-03-15 18:41:39 +03:00
|
|
|
_coreEvalNoDisambiguate :: Bool
|
2022-09-14 17:16:15 +03:00
|
|
|
}
|
|
|
|
deriving stock (Data)
|
|
|
|
|
|
|
|
makeLenses ''CoreEvalOptions
|
|
|
|
|
2022-09-15 17:26:02 +03:00
|
|
|
instance CanonicalProjection CoreEvalOptions Core.Options where
|
|
|
|
project c =
|
|
|
|
Core.defaultOptions
|
2023-03-15 18:41:39 +03:00
|
|
|
{ Core._optShowDeBruijnIndices = c ^. coreEvalShowDeBruijn,
|
2023-03-30 14:23:40 +03:00
|
|
|
Core._optShowIdentIds = c ^. coreEvalShowIdentIds,
|
|
|
|
Core._optShowArgsNum = c ^. coreEvalShowArgsNum
|
2022-09-15 17:26:02 +03:00
|
|
|
}
|
|
|
|
|
2022-11-07 16:47:56 +03:00
|
|
|
instance CanonicalProjection CoreEvalOptions Eval.EvalOptions where
|
|
|
|
project c =
|
|
|
|
Eval.EvalOptions
|
|
|
|
{ _evalInputFile = c ^. coreEvalInputFile,
|
2023-03-15 18:41:39 +03:00
|
|
|
_evalNoIO = c ^. coreEvalNoIO,
|
2023-06-06 13:35:01 +03:00
|
|
|
_evalNoDisambiguate = c ^. coreEvalNoDisambiguate,
|
|
|
|
_evalPrintValues = False
|
2022-11-07 16:47:56 +03:00
|
|
|
}
|
|
|
|
|
2022-09-14 17:16:15 +03:00
|
|
|
parseCoreEvalOptions :: Parser CoreEvalOptions
|
|
|
|
parseCoreEvalOptions = do
|
|
|
|
_coreEvalNoIO <-
|
|
|
|
switch
|
|
|
|
( long "no-io"
|
2023-10-25 13:02:12 +03:00
|
|
|
<> help "Do not interpret the IO effects"
|
2022-09-14 17:16:15 +03:00
|
|
|
)
|
2022-09-15 17:26:02 +03:00
|
|
|
_coreEvalShowDeBruijn <- optDeBruijn
|
2023-03-15 18:41:39 +03:00
|
|
|
_coreEvalShowIdentIds <- optIdentIds
|
2023-03-30 14:23:40 +03:00
|
|
|
_coreEvalShowArgsNum <- optArgsNum
|
2023-03-15 18:41:39 +03:00
|
|
|
_coreEvalNoDisambiguate <- optNoDisambiguate
|
2023-10-25 13:02:12 +03:00
|
|
|
_coreEvalInputFile <- parseInputFile FileExtJuvixCore
|
2022-09-14 17:16:15 +03:00
|
|
|
pure CoreEvalOptions {..}
|