mirror of
https://github.com/anoma/juvix.git
synced 2024-12-01 00:04:58 +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:
parent
3d012cc8fb
commit
c4d519ae09
@ -435,7 +435,7 @@ typeArity = go
|
|||||||
go :: Expression -> Arity
|
go :: Expression -> Arity
|
||||||
go = \case
|
go = \case
|
||||||
ExpressionIden i -> goIden i
|
ExpressionIden i -> goIden i
|
||||||
ExpressionApplication {} -> ArityUnit
|
ExpressionApplication a -> goApplication a
|
||||||
ExpressionLiteral {} -> ArityUnknown
|
ExpressionLiteral {} -> ArityUnknown
|
||||||
ExpressionFunction f -> ArityFunction (goFun f)
|
ExpressionFunction f -> ArityFunction (goFun f)
|
||||||
ExpressionHole {} -> ArityUnknown
|
ExpressionHole {} -> ArityUnknown
|
||||||
@ -445,6 +445,14 @@ typeArity = go
|
|||||||
ExpressionSimpleLambda {} -> simplelambda
|
ExpressionSimpleLambda {} -> simplelambda
|
||||||
ExpressionLet l -> goLet l
|
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 :: Let -> Arity
|
||||||
goLet l = typeArity (l ^. letExpression)
|
goLet l = typeArity (l ^. letExpression)
|
||||||
|
|
||||||
|
@ -34,3 +34,15 @@ p a := mkPair t a a;
|
|||||||
|
|
||||||
x' : flip Pair (id _) T2;
|
x' : flip Pair (id _) T2;
|
||||||
x' := mkPair x t2 t;
|
x' := mkPair x t2 t;
|
||||||
|
|
||||||
|
funAlias : Type -> Type;
|
||||||
|
funAlias a := a -> a;
|
||||||
|
|
||||||
|
f : funAlias T;
|
||||||
|
f :=
|
||||||
|
\ {
|
||||||
|
| t := t
|
||||||
|
};
|
||||||
|
|
||||||
|
f' : funAlias T;
|
||||||
|
f' t := t;
|
||||||
|
Loading…
Reference in New Issue
Block a user