1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-05 22:46:08 +03:00

Improve arity inference for repl expressions (#1762)

Closes #1721.

Now the arity checker does not add an unnecessary hole and so the repl
displays the type properly:

![image](https://user-images.githubusercontent.com/5511599/214322656-706d6bd7-5fbe-42dd-adf7-cc9170d001b0.png)
This commit is contained in:
janmasrovira 2023-01-24 16:49:37 +01:00 committed by GitHub
parent 88ab622353
commit c1020f9adb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -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

View File

@ -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) =>

View File

@ -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
@ -180,4 +189,3 @@ tests:
contains: |
suc (suc (suc zero))
exit-status: 0