1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-02 20:43:17 +03:00
juvix/app/Commands/Eval/Options.hs
Łukasz Czajka 2d798ec31c
New compilation pipeline (#1832)
* Depends on PR #1824 
* Closes #1556 
* Closes #1825 
* Closes #1843
* Closes #1729 
* Closes #1596 
* Closes #1343 
* Closes #1382 
* Closes #1867 
* Closes #1876 
* Changes the `juvix compile` command to use the new pipeline.
* Removes the `juvix dev minic` command and the `BackendC` tests.
* Adds the `juvix eval` command.
* Fixes bugs in the Nat-to-integer conversion.
* Fixes bugs in the Internal-to-Core and Core-to-Core.Stripped
translations.
* Fixes bugs in the RemoveTypeArgs transformation.
* Fixes bugs in lambda-lifting (incorrect de Bruijn indices in the types
of added binders).
* Fixes several other bugs in the compilation pipeline.
* Adds a separate EtaExpandApps transformation to avoid quadratic
runtime in the Internal-to-Core translation due to repeated calls to
etaExpandApps.
* Changes Internal-to-Core to avoid generating matches on values which
don't have an inductive type.

---------

Co-authored-by: Paul Cadman <git@paulcadman.dev>
Co-authored-by: janmasrovira <janmasrovira@gmail.com>
2023-03-14 16:24:07 +01:00

52 lines
1.3 KiB
Haskell

module Commands.Eval.Options where
import CommonOptions
import Evaluator qualified as Eval
import Juvix.Compiler.Core.Pretty.Options qualified as Core
data EvalOptions = EvalOptions
{ _evalShowDeBruijn :: Bool,
_evalNoIO :: Bool,
_evalInputFile :: AppPath File,
_evalSymbolName :: Maybe Text
}
deriving stock (Data)
makeLenses ''EvalOptions
instance CanonicalProjection EvalOptions Core.Options where
project c =
Core.defaultOptions
{ Core._optShowDeBruijnIndices = c ^. evalShowDeBruijn
}
instance CanonicalProjection EvalOptions Eval.EvalOptions where
project c =
Eval.EvalOptions
{ _evalInputFile = c ^. evalInputFile,
_evalNoIO = c ^. evalNoIO
}
parseEvalOptions :: Parser EvalOptions
parseEvalOptions = do
_evalShowDeBruijn <-
switch
( long "show-de-bruijn"
<> help "Show variable de Bruijn indices"
)
_evalNoIO <-
switch
( long "no-io"
<> help "Don't interpret the IO effects"
)
_evalInputFile <- parseInputJuvixFile
_evalSymbolName <-
optional $
strOption
( long "symbol-name"
<> short 's'
<> help "Evaluate a specific function identifier (default: main)"
<> metavar "NAME"
)
pure EvalOptions {..}