-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the JuvixCore framework and its evaluator (#1421)
- Loading branch information
Showing
144 changed files
with
4,930 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
module Commands.Dev.Core where | ||
|
||
import Juvix.Prelude hiding (Doc) | ||
import Options.Applicative | ||
|
||
data CoreCommand | ||
= Repl CoreReplOptions | ||
| Eval CoreEvalOptions | ||
|
||
newtype CoreReplOptions = CoreReplOptions | ||
{ _coreReplShowDeBruijn :: Bool | ||
} | ||
|
||
newtype CoreEvalOptions = CoreEvalOptions | ||
{ _coreEvalNoIO :: Bool | ||
} | ||
|
||
makeLenses ''CoreReplOptions | ||
makeLenses ''CoreEvalOptions | ||
|
||
defaultCoreEvalOptions :: CoreEvalOptions | ||
defaultCoreEvalOptions = | ||
CoreEvalOptions | ||
{ _coreEvalNoIO = False | ||
} | ||
|
||
parseCoreCommand :: Parser CoreCommand | ||
parseCoreCommand = | ||
hsubparser $ | ||
mconcat | ||
[ commandRepl, | ||
commandEval | ||
] | ||
where | ||
commandRepl :: Mod CommandFields CoreCommand | ||
commandRepl = command "repl" replInfo | ||
|
||
commandEval :: Mod CommandFields CoreCommand | ||
commandEval = command "eval" evalInfo | ||
|
||
replInfo :: ParserInfo CoreCommand | ||
replInfo = | ||
info | ||
(Repl <$> parseCoreReplOptions) | ||
(progDesc "Start an interactive session of the JuvixCore evaluator") | ||
|
||
evalInfo :: ParserInfo CoreCommand | ||
evalInfo = | ||
info | ||
(Eval <$> parseCoreEvalOptions) | ||
(progDesc "Evaluate a JuvixCore file and pretty print the result") | ||
|
||
parseCoreEvalOptions :: Parser CoreEvalOptions | ||
parseCoreEvalOptions = do | ||
_coreEvalNoIO <- | ||
switch | ||
( long "no-io" | ||
<> help "Don't interpret the IO effects" | ||
) | ||
pure CoreEvalOptions {..} | ||
|
||
parseCoreReplOptions :: Parser CoreReplOptions | ||
parseCoreReplOptions = do | ||
_coreReplShowDeBruijn <- | ||
switch | ||
( long "show-de-bruijn" | ||
<> help "Show variable de Bruijn indices" | ||
) | ||
pure CoreReplOptions {..} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.