mirror of
https://github.com/unisonweb/unison.git
synced 2024-10-26 02:55:19 +03:00
Modify kind inference constraint generation order
add all decl constraints in component before any constructor constraints
This commit is contained in:
parent
5571274311
commit
545fb19261
@ -241,7 +241,7 @@ declComponentConstraintTree decls = do
|
|||||||
-- Add a kind variable for every datatype
|
-- Add a kind variable for every datatype
|
||||||
declKind <- pushType (Type.ref (DD.annotation $ asDataDecl decl) ref)
|
declKind <- pushType (Type.ref (DD.annotation $ asDataDecl decl) ref)
|
||||||
pure (ref, decl, declKind)
|
pure (ref, decl, declKind)
|
||||||
cts <- for decls \(ref, decl, declKind) -> do
|
(declConstraints, constructorConstraints) <- unzip <$> for decls \(ref, decl, declKind) -> do
|
||||||
let declAnn = DD.annotation $ asDataDecl decl
|
let declAnn = DD.annotation $ asDataDecl decl
|
||||||
let declType = Type.ref declAnn ref
|
let declType = Type.ref declAnn ref
|
||||||
-- Unify the datatype with @k_1 -> ... -> k_n -> *@ where @n@ is
|
-- Unify the datatype with @k_1 -> ... -> k_n -> *@ where @n@ is
|
||||||
@ -275,8 +275,8 @@ declComponentConstraintTree decls = do
|
|||||||
let finalDeclConstraints = case decl of
|
let finalDeclConstraints = case decl of
|
||||||
Left _effectDecl -> Constraint (IsAbility fullyAppliedKind (Provenance DeclDefinition declAnn)) declConstraints
|
Left _effectDecl -> Constraint (IsAbility fullyAppliedKind (Provenance DeclDefinition declAnn)) declConstraints
|
||||||
Right _dataDecl -> Constraint (IsType fullyAppliedKind (Provenance DeclDefinition declAnn)) declConstraints
|
Right _dataDecl -> Constraint (IsType fullyAppliedKind (Provenance DeclDefinition declAnn)) declConstraints
|
||||||
pure (StrictOrder finalDeclConstraints constructorConstraints)
|
pure (finalDeclConstraints, constructorConstraints)
|
||||||
pure (Node cts)
|
pure (Node declConstraints `StrictOrder` Node constructorConstraints)
|
||||||
|
|
||||||
-- | This is a helper to unify the kind constraints on type variables
|
-- | This is a helper to unify the kind constraints on type variables
|
||||||
-- across a decl's constructors.
|
-- across a decl's constructors.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
```unison
|
```unison:error
|
||||||
structural type Foo f
|
structural type Foo f
|
||||||
= Foo (f ())
|
= Foo (f ())
|
||||||
unique type Baz = Baz (Foo Bar)
|
unique type Baz = Baz (Foo Bar)
|
||||||
|
@ -10,25 +10,9 @@ unique type Bar
|
|||||||
```ucm
|
```ucm
|
||||||
|
|
||||||
Kind mismatch arising from
|
Kind mismatch arising from
|
||||||
5 | unique type Bar
|
3 | unique type Baz = Baz (Foo Bar)
|
||||||
6 | = Bar Baz
|
|
||||||
|
|
||||||
Expected kind: Type
|
Foo expects an argument of kind: Type -> Type; however, it
|
||||||
Given kind: Type -> Type
|
is applied to Bar which has kind: Type.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
🛑
|
|
||||||
|
|
||||||
The transcript failed due to an error in the stanza above. The error is:
|
|
||||||
|
|
||||||
|
|
||||||
Kind mismatch arising from
|
|
||||||
5 | unique type Bar
|
|
||||||
6 | = Bar Baz
|
|
||||||
|
|
||||||
Expected kind: Type
|
|
||||||
Given kind: Type -> Type
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user