1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-14 08:27:03 +03:00
juvix/app/Commands/Dev/Options.hs
Jonathan Cubides 9a4da4cab8
Add Geb Backend Evaluator with some extra subcommands (#1808)
This PR introduces an evaluator for the Geb STLC interface/fragment and
other related commands, including a REPL to interact with his backend.

-
https://github.com/anoma/geb/blob/mariari/binaries/src/specs/lambda.lisp

We have included a REPL and support for commands such as read and eval
here. Check out:

```
juvix dev geb --help
```

- [x] Add Geb evaluator with the two basic eval strategies.
- [x] Add quasi quoter: return morphisms from typed geb values.
- [x] Add type/object inference for morphisms.
- [x] All combined: morphisms-eval-to-morphisms
- [x] Parse and pretty printer Geb values (without quoting them)
- [x] Parse files containing Geb terms:
- [x] Saved in a .lisp file according to anoma/geb example (typed
object).
  - [x] Store in a .geb file simple as simple lisp expression.
- [x] Add related commands to the CLI for `dev geb`:
  - [x] Subcommand: eval
  - [x] Subcommand: read
  - [x] Subcommand: infer
  - [x] Subcommand: repl
  - [x] Subcommand: check 
- [x] Minor changes `hom` by `!->` in the Geb prettyprinter
- [x] Add tests for:
   - [x] New subcommand (smoke tests)
   - [x] Eval

Issues to solve after merging this PR: 

- Add location to Geb ast for proper error location.
- Add tests for all related subcommands, e.g. check, and infer.
- Check compilation from Core to Geb: (run inferObject with the type
provided by the core node).
- [x] Update the vs code-plugin to load Geb repl and eval.
(31994c8684)
2023-02-22 15:27:40 +01:00

136 lines
3.5 KiB
Haskell

module Commands.Dev.Options
( module Commands.Dev.Options,
module Commands.Dev.Asm.Options,
module Commands.Dev.Core.Options,
module Commands.Dev.Geb.Options,
module Commands.Dev.Internal.Options,
module Commands.Dev.Parse.Options,
module Commands.Dev.Highlight.Options,
module Commands.Dev.Scope.Options,
module Commands.Dev.Termination.Options,
module Commands.Dev.DisplayRoot.Options,
)
where
import Commands.Dev.Asm.Options hiding (Compile)
import Commands.Dev.Core.Options
import Commands.Dev.DisplayRoot.Options
import Commands.Dev.Geb.Options
import Commands.Dev.Highlight.Options
import Commands.Dev.Internal.Options
import Commands.Dev.MiniC.Options
import Commands.Dev.Parse.Options
import Commands.Dev.Runtime.Options
import Commands.Dev.Scope.Options
import Commands.Dev.Termination.Options
import CommonOptions
data DevCommand
= DisplayRoot RootOptions
| Highlight HighlightOptions
| Internal InternalCommand
| Core CoreCommand
| Geb GebCommand
| Asm AsmCommand
| Runtime RuntimeCommand
| MiniC MiniCOptions
| Parse ParseOptions
| Scope ScopeOptions
| Termination TerminationCommand
deriving stock (Data)
parseDevCommand :: Parser DevCommand
parseDevCommand =
hsubparser
( mconcat
[ commandHighlight,
commandInternal,
commandCore,
commandGeb,
commandAsm,
commandRuntime,
commandMiniC,
commandParse,
commandScope,
commandShowRoot,
commandTermination
]
)
commandHighlight :: Mod CommandFields DevCommand
commandHighlight =
command "highlight" $
info
(Highlight <$> parseHighlight)
(progDesc "Highlight a Juvix file")
commandMiniC :: Mod CommandFields DevCommand
commandMiniC =
command "minic" $
info
(MiniC <$> parseMiniC)
(progDesc "Translate a Juvix file to MiniC")
commandInternal :: Mod CommandFields DevCommand
commandInternal =
command "internal" $
info
(Internal <$> parseInternalCommand)
(progDesc "Subcommands related to Internal")
commandGeb :: Mod CommandFields DevCommand
commandGeb =
command "geb" $
info
(Geb <$> parseGebCommand)
(progDesc "Subcommands related to JuvixGeb")
commandCore :: Mod CommandFields DevCommand
commandCore =
command "core" $
info
(Core <$> parseCoreCommand)
(progDesc "Subcommands related to JuvixCore")
commandAsm :: Mod CommandFields DevCommand
commandAsm =
command "asm" $
info
(Asm <$> parseAsmCommand)
(progDesc "Subcommands related to JuvixAsm")
commandRuntime :: Mod CommandFields DevCommand
commandRuntime =
command "runtime" $
info
(Runtime <$> parseRuntimeCommand)
(progDesc "Subcommands related to the Juvix runtime")
commandParse :: Mod CommandFields DevCommand
commandParse =
command "parse" $
info
(Parse <$> parseParse)
(progDesc "Parse a Juvix file")
commandScope :: Mod CommandFields DevCommand
commandScope =
command "scope" $
info
(Scope <$> parseScope)
(progDesc "Parse and scope a Juvix file")
commandShowRoot :: Mod CommandFields DevCommand
commandShowRoot =
command "root" $
info
(DisplayRoot <$> parseRoot)
(progDesc "Show the root path for a Juvix project")
commandTermination :: Mod CommandFields DevCommand
commandTermination =
command "termination" $
info
(Termination <$> parseTerminationCommand)
(progDesc "Subcommands related to termination checking")