2023-02-10 14:37:28 +03:00
|
|
|
module Commands.Dev.Core.FromConcrete.Options where
|
|
|
|
|
|
|
|
import CommonOptions
|
|
|
|
import Evaluator qualified as Eval
|
|
|
|
import Juvix.Compiler.Core.Data.TransformationId
|
|
|
|
import Juvix.Compiler.Core.Pretty.Options qualified as Core
|
|
|
|
|
|
|
|
data CoreFromConcreteOptions = CoreFromConcreteOptions
|
|
|
|
{ _coreFromConcreteTransformations :: [TransformationId],
|
|
|
|
_coreFromConcreteShowDeBruijn :: Bool,
|
2023-03-15 18:41:39 +03:00
|
|
|
_coreFromConcreteShowIdentIds :: Bool,
|
2023-03-30 14:23:40 +03:00
|
|
|
_coreFromConcreteShowArgsNum :: Bool,
|
2023-03-15 18:41:39 +03:00
|
|
|
_coreFromConcreteNoDisambiguate :: Bool,
|
2023-03-14 18:24:07 +03:00
|
|
|
_coreFromConcreteFilter :: Bool,
|
2023-02-10 14:37:28 +03:00
|
|
|
_coreFromConcreteNoIO :: Bool,
|
|
|
|
_coreFromConcreteEval :: Bool,
|
2023-05-15 19:01:40 +03:00
|
|
|
_coreFromConcreteNormalize :: Bool,
|
2023-02-10 14:37:28 +03:00
|
|
|
_coreFromConcreteInputFile :: AppPath File,
|
|
|
|
_coreFromConcreteSymbolName :: Maybe Text
|
|
|
|
}
|
|
|
|
deriving stock (Data)
|
|
|
|
|
|
|
|
makeLenses ''CoreFromConcreteOptions
|
|
|
|
|
|
|
|
instance CanonicalProjection CoreFromConcreteOptions Core.Options where
|
|
|
|
project c =
|
|
|
|
Core.defaultOptions
|
2023-03-15 18:41:39 +03:00
|
|
|
{ Core._optShowDeBruijnIndices = c ^. coreFromConcreteShowDeBruijn,
|
2023-03-30 14:23:40 +03:00
|
|
|
Core._optShowIdentIds = c ^. coreFromConcreteShowIdentIds,
|
|
|
|
Core._optShowArgsNum = c ^. coreFromConcreteShowArgsNum
|
2023-02-10 14:37:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
instance CanonicalProjection CoreFromConcreteOptions Eval.EvalOptions where
|
|
|
|
project c =
|
|
|
|
Eval.EvalOptions
|
|
|
|
{ _evalInputFile = c ^. coreFromConcreteInputFile,
|
2023-03-15 18:41:39 +03:00
|
|
|
_evalNoIO = c ^. coreFromConcreteNoIO,
|
|
|
|
_evalNoDisambiguate = c ^. coreFromConcreteNoDisambiguate
|
2023-02-10 14:37:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
parseCoreFromConcreteOptions :: Parser CoreFromConcreteOptions
|
|
|
|
parseCoreFromConcreteOptions = do
|
|
|
|
_coreFromConcreteTransformations <- optTransformationIds
|
2023-03-15 18:41:39 +03:00
|
|
|
_coreFromConcreteShowDeBruijn <- optDeBruijn
|
|
|
|
_coreFromConcreteShowIdentIds <- optIdentIds
|
2023-03-30 14:23:40 +03:00
|
|
|
_coreFromConcreteShowArgsNum <- optArgsNum
|
2023-03-15 18:41:39 +03:00
|
|
|
_coreFromConcreteNoDisambiguate <- optNoDisambiguate
|
2023-03-14 18:24:07 +03:00
|
|
|
_coreFromConcreteFilter <-
|
|
|
|
switch
|
|
|
|
( long "filter"
|
|
|
|
<> help "Filter out the functions not from the input module"
|
|
|
|
)
|
2023-02-10 14:37:28 +03:00
|
|
|
_coreFromConcreteEval <-
|
|
|
|
switch
|
|
|
|
( long "eval"
|
|
|
|
<> help "Evaluate the main function"
|
|
|
|
)
|
2023-05-15 19:01:40 +03:00
|
|
|
_coreFromConcreteNormalize <-
|
|
|
|
switch
|
|
|
|
( long "normalize"
|
|
|
|
<> help "Normalize the main function"
|
|
|
|
)
|
2023-02-10 14:37:28 +03:00
|
|
|
_coreFromConcreteNoIO <-
|
|
|
|
switch
|
|
|
|
( long "no-io"
|
|
|
|
<> help "Don't interpret the IO effects"
|
|
|
|
)
|
|
|
|
_coreFromConcreteInputFile <- parseInputJuvixFile
|
|
|
|
_coreFromConcreteSymbolName <-
|
|
|
|
optional $
|
|
|
|
strOption
|
|
|
|
( long "symbol-name"
|
|
|
|
<> short 's'
|
|
|
|
<> help "Print/eval a specific function identifier (default for eval: main)"
|
|
|
|
<> metavar "NAME"
|
|
|
|
)
|
|
|
|
pure CoreFromConcreteOptions {..}
|