1
1
mirror of https://github.com/anoma/juvix.git synced 2024-11-24 08:45:51 +03:00

Support positive arity typealias in arity checker (#2021)

Currently the arity checker assumes that applications within a type
signature have arity unit. This is not the case where a type alias
function is used within a type signature that returns a positive arity
function type.

For example:

```
type T :=
  | t : T;

funAlias : Type -> Type;
funAlias a := a -> a;

f : funAlias T;
f t := t;
```

* Closes https://github.com/anoma/juvix/issues/2020

Co-authored-by: Co-authored-by: janmasrovira <janmasrovira@gmail.com>
This commit is contained in:
Paul Cadman 2023-04-20 11:07:37 +01:00 committed by GitHub
parent 3d012cc8fb
commit c4d519ae09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -435,7 +435,7 @@ typeArity = go
go :: Expression -> Arity
go = \case
ExpressionIden i -> goIden i
ExpressionApplication {} -> ArityUnit
ExpressionApplication a -> goApplication a
ExpressionLiteral {} -> ArityUnknown
ExpressionFunction f -> ArityFunction (goFun f)
ExpressionHole {} -> ArityUnknown
@ -445,6 +445,14 @@ typeArity = go
ExpressionSimpleLambda {} -> simplelambda
ExpressionLet l -> goLet l
goApplication :: Application -> Arity
goApplication a = case lhs of
ExpressionIden IdenInductive {} -> ArityUnit
_ -> ArityUnknown
where
lhs :: Expression
lhs = fst (unfoldApplication a)
goLet :: Let -> Arity
goLet l = typeArity (l ^. letExpression)

View File

@ -34,3 +34,15 @@ p a := mkPair t a a;
x' : flip Pair (id _) T2;
x' := mkPair x t2 t;
funAlias : Type -> Type;
funAlias a := a -> a;
f : funAlias T;
f :=
\ {
| t := t
};
f' : funAlias T;
f' t := t;