mirror of
https://github.com/anoma/juvix.git
synced 2024-12-21 13:51:38 +03:00
9a4da4cab8
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
)
41 lines
1.6 KiB
Haskell
41 lines
1.6 KiB
Haskell
module Commands.Dev.Core.Read where
|
|
|
|
import Commands.Base
|
|
import Commands.Dev.Core.Read.Options
|
|
import Evaluator qualified as Eval
|
|
import Juvix.Compiler.Core.Pretty qualified as Core
|
|
import Juvix.Compiler.Core.Scoper qualified as Scoper
|
|
import Juvix.Compiler.Core.Transformation qualified as Core
|
|
import Juvix.Compiler.Core.Translation.FromSource qualified as Core
|
|
|
|
runCommand ::
|
|
forall r a.
|
|
( Members '[Embed IO, App] r,
|
|
CanonicalProjection a Eval.EvalOptions,
|
|
CanonicalProjection a Core.Options,
|
|
CanonicalProjection a CoreReadOptions
|
|
) =>
|
|
a ->
|
|
Sem r ()
|
|
runCommand opts = do
|
|
inputFile :: Path Abs File <- someBaseToAbs' sinputFile
|
|
s' <- embed . readFile . toFilePath $ inputFile
|
|
tab <- getRight (mapLeft JuvixError (Core.runParserMain inputFile Core.emptyInfoTable s'))
|
|
let tab' = Core.applyTransformations (project opts ^. coreReadTransformations) tab
|
|
embed (Scoper.scopeTrace tab')
|
|
unless (project opts ^. coreReadNoPrint) $ do
|
|
renderStdOut (Core.ppOut opts tab')
|
|
whenJust (tab' ^. Core.infoMain) $ \sym -> doEval tab' (fromJust $ tab' ^. Core.identContext . at sym)
|
|
where
|
|
doEval :: Core.InfoTable -> Core.Node -> Sem r ()
|
|
doEval tab' node =
|
|
if
|
|
| project opts ^. coreReadEval -> do
|
|
embed (putStrLn "--------------------------------")
|
|
embed (putStrLn "| Eval |")
|
|
embed (putStrLn "--------------------------------")
|
|
Eval.evalAndPrint opts tab' node
|
|
| otherwise -> return ()
|
|
sinputFile :: SomeBase File
|
|
sinputFile = project opts ^. coreReadInputFile . pathPath
|