1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-14 17:32:00 +03:00
juvix/app/Commands/Dev/Repl/Options.hs
Łukasz Czajka 34b0969141
Pretty print JuvixCore values consistently with Juvix syntax (#1988)
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
2023-04-12 12:52:40 +02:00

29 lines
767 B
Haskell

module Commands.Dev.Repl.Options where
import Commands.Repl.Options
import CommonOptions
import Juvix.Compiler.Core.Data.TransformationId (toEvalTransformations)
parseDevRepl :: Parser ReplOptions
parseDevRepl = do
let _replPrintValues = False
_replInputFile <- optional parseInputJuvixFile
_replTransformations <- do
ts <- optTransformationIds
pure $
if
| null ts -> toEvalTransformations
| otherwise -> ts
_replNoDisambiguate <- optNoDisambiguate
_replShowDeBruijn <-
switch
( long "show-de-bruijn"
<> help "Show variable de Bruijn indices"
)
_replNoPrelude <-
switch
( long "no-prelude"
<> help "Do not load the Prelude module on launch"
)
pure ReplOptions {..}