Skip to content

Commit

Permalink
Support new import ... open syntax in REPL
Browse files Browse the repository at this point in the history
Similar to #2098 which introducted
the new `import ... open` syntax the old syntax is still supported.

The `try` must be removed when the old `open import ...` syntax is
removed.
  • Loading branch information
paulcadman committed Jun 1, 2023
1 parent c66213e commit 2f42f37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Juvix/Compiler/Concrete/Translation/FromSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ topModuleDef = do
replInput :: forall r. Members '[Files, PathResolver, InfoTableBuilder, JudocStash, NameIdGen, Error ParserError, State (Maybe ParsedPragmas)] r => ParsecS r ReplInput
replInput =
P.label "<repl input>" $
(ReplExpression <$> parseExpressionAtoms)
<|> (ReplImport <$> import_)
<|> (ReplOpenImport <$> openModule)
ReplExpression <$> parseExpressionAtoms
<|> P.try (ReplOpenImport <$> newOpenSyntax)
<|> ReplImport <$> import_
<|> ReplOpenImport <$> openModule

--------------------------------------------------------------------------------
-- Symbols and names
Expand Down
9 changes: 9 additions & 0 deletions tests/smoke/Commands/repl.smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,15 @@ tests:
contains: "true"
exit-status: 0

- name: open-import-from-stdlib-new-syntax
command:
- juvix
- repl
stdin: "import Stdlib.Data.Int.Ord open\n1 == 1"
stdout:
contains: "true"
exit-status: 0

- name: infix-constructors
command:
- juvix
Expand Down

0 comments on commit 2f42f37

Please sign in to comment.