2022-11-07 16:47:56 +03:00
|
|
|
module Commands.Repl.Options where
|
|
|
|
|
|
|
|
import CommonOptions
|
2023-01-04 19:09:41 +03:00
|
|
|
import Juvix.Compiler.Core.Pretty.Options qualified as Core
|
2023-02-01 16:00:06 +03:00
|
|
|
import Juvix.Compiler.Core.Transformation
|
2022-11-07 16:47:56 +03:00
|
|
|
|
2022-11-07 20:43:30 +03:00
|
|
|
data ReplOptions = ReplOptions
|
2022-12-20 15:05:40 +03:00
|
|
|
{ _replInputFile :: Maybe (AppPath File),
|
2023-01-04 19:09:41 +03:00
|
|
|
_replShowDeBruijn :: Bool,
|
2023-02-01 16:00:06 +03:00
|
|
|
_replNoPrelude :: Bool,
|
2023-03-31 01:57:44 +03:00
|
|
|
_replTransformations :: [TransformationId],
|
2023-04-12 13:52:40 +03:00
|
|
|
_replNoDisambiguate :: Bool,
|
|
|
|
_replPrintValues :: Bool
|
2022-11-07 20:43:30 +03:00
|
|
|
}
|
2022-11-07 16:47:56 +03:00
|
|
|
deriving stock (Data)
|
|
|
|
|
|
|
|
makeLenses ''ReplOptions
|
|
|
|
|
2023-01-04 19:09:41 +03:00
|
|
|
instance CanonicalProjection ReplOptions Core.Options where
|
|
|
|
project c =
|
|
|
|
Core.defaultOptions
|
|
|
|
{ Core._optShowDeBruijnIndices = c ^. replShowDeBruijn
|
|
|
|
}
|
|
|
|
|
2022-11-07 16:47:56 +03:00
|
|
|
parseRepl :: Parser ReplOptions
|
|
|
|
parseRepl = do
|
2023-03-31 01:57:44 +03:00
|
|
|
let _replTransformations = toEvalTransformations
|
|
|
|
_replShowDeBruijn = False
|
2023-04-03 11:58:08 +03:00
|
|
|
_replNoDisambiguate = False
|
2023-04-12 13:52:40 +03:00
|
|
|
_replPrintValues = True
|
2022-11-07 16:47:56 +03:00
|
|
|
_replInputFile <- optional parseInputJuvixFile
|
2022-11-07 20:43:30 +03:00
|
|
|
_replNoPrelude <-
|
|
|
|
switch
|
|
|
|
( long "no-prelude"
|
|
|
|
<> help "Do not load the Prelude module on launch"
|
|
|
|
)
|
2022-11-07 16:47:56 +03:00
|
|
|
pure ReplOptions {..}
|