Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve arity inference for repl expressions #1762

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Internal/Translation/FromInternal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ arityCheckExpression ::
Sem r Expression
arityCheckExpression InternalResult {..} exp =
mapError (JuvixError @ArityChecking.ArityCheckerError) $
runReader table (ArityChecking.withEmptyLocalVars (ArityChecking.checkExpression ArityChecking.ArityUnknown exp))
runReader table (ArityChecking.inferReplExpression exp)
where
table :: InfoTable
table = buildTable _resultModules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ withEmptyLocalVars = runReader emptyLocalVars
arityLet :: (Members '[Reader InfoTable] r) => Let -> Sem r Arity
arityLet l = guessArity (l ^. letExpression)

inferReplExpression :: Members '[Reader InfoTable, NameIdGen, Error ArityCheckerError] r => Expression -> Sem r Expression
inferReplExpression e = do
ari <- guessArity e
withEmptyLocalVars (checkExpression ari e)

guessArity ::
forall r.
(Members '[Reader InfoTable] r) =>
Expand Down
10 changes: 9 additions & 1 deletion tests/smoke/Commands/repl.smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ tests:
Stdlib.Prelude> \1
exit-status: 0

- name: check-type-null
command:
- juvix
- repl
stdout:
contains: "{A : Type} → List A → Bool"
stdin: ":type null"
exit-status: 0

- name: check-type-suc
command:
- juvix
Expand Down Expand Up @@ -180,4 +189,3 @@ tests:
contains: |
suc (suc (suc zero))
exit-status: 0