mirror of
https://github.com/anoma/juvix.git
synced 2024-12-15 01:52:11 +03:00
34b0969141
This PR implements pretty printing of evaluation results consistently with Juvix syntax. The printed values do not necessarily originate directly from the source code. All functions/lambdas are printed as `<fun>`. The same mechanism is used to implement pretty printing of unmatched pattern examples. Juvix REPL now uses the new value printing mechanism to display evaluation results. Typing `nil` in the REPL will now just display `nil`. The command `juvix dev repl` still prints raw JuvixCore terms. * Closes #1957 * Closes #1985
38 lines
1020 B
Haskell
38 lines
1020 B
Haskell
module Commands.Repl.Options where
|
|
|
|
import CommonOptions
|
|
import Juvix.Compiler.Core.Pretty.Options qualified as Core
|
|
import Juvix.Compiler.Core.Transformation
|
|
|
|
data ReplOptions = ReplOptions
|
|
{ _replInputFile :: Maybe (AppPath File),
|
|
_replShowDeBruijn :: Bool,
|
|
_replNoPrelude :: Bool,
|
|
_replTransformations :: [TransformationId],
|
|
_replNoDisambiguate :: Bool,
|
|
_replPrintValues :: Bool
|
|
}
|
|
deriving stock (Data)
|
|
|
|
makeLenses ''ReplOptions
|
|
|
|
instance CanonicalProjection ReplOptions Core.Options where
|
|
project c =
|
|
Core.defaultOptions
|
|
{ Core._optShowDeBruijnIndices = c ^. replShowDeBruijn
|
|
}
|
|
|
|
parseRepl :: Parser ReplOptions
|
|
parseRepl = do
|
|
let _replTransformations = toEvalTransformations
|
|
_replShowDeBruijn = False
|
|
_replNoDisambiguate = False
|
|
_replPrintValues = True
|
|
_replInputFile <- optional parseInputJuvixFile
|
|
_replNoPrelude <-
|
|
switch
|
|
( long "no-prelude"
|
|
<> help "Do not load the Prelude module on launch"
|
|
)
|
|
pure ReplOptions {..}
|