1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 01:52:11 +03:00
juvix/app/Commands/Dev/Geb/Read.hs

23 lines
694 B
Haskell
Raw Normal View History

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. (https://github.com/anoma/vscode-juvix/commit/31994c8684e9b44a62d58ac13304b9e04503410c)
2023-02-22 17:27:40 +03:00
module Commands.Dev.Geb.Read where
import Commands.Base
import Commands.Dev.Geb.Read.Options
import Juvix.Compiler.Backend.Geb.Pretty qualified as Geb
import Juvix.Compiler.Backend.Geb.Translation.FromSource qualified as Geb
runCommand ::
forall r.
(Member App r, Member (Embed IO) r) =>
GebReadOptions ->
Sem r ()
runCommand opts = do
let b :: SomeBase File
b = opts ^. gebReadOptionsInputFile . pathPath
f :: Path Abs File <- someBaseToAbs' b
content :: Text <- embed (readFile (toFilePath f))
case Geb.runParser f content of
Left err -> exitJuvixError (JuvixError err)
Right gebTerm -> do
renderStdOut (Geb.ppOut opts gebTerm)
embed (putStrLn "")