mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +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
|
||||
declKind <- pushType (Type.ref (DD.annotation $ asDataDecl decl) ref)
|
||||
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 declType = Type.ref declAnn ref
|
||||
-- Unify the datatype with @k_1 -> ... -> k_n -> *@ where @n@ is
|
||||
@ -275,8 +275,8 @@ declComponentConstraintTree decls = do
|
||||
let finalDeclConstraints = case decl of
|
||||
Left _effectDecl -> Constraint (IsAbility fullyAppliedKind (Provenance DeclDefinition declAnn)) declConstraints
|
||||
Right _dataDecl -> Constraint (IsType fullyAppliedKind (Provenance DeclDefinition declAnn)) declConstraints
|
||||
pure (StrictOrder finalDeclConstraints constructorConstraints)
|
||||
pure (Node cts)
|
||||
pure (finalDeclConstraints, constructorConstraints)
|
||||
pure (Node declConstraints `StrictOrder` Node constructorConstraints)
|
||||
|
||||
-- | This is a helper to unify the kind constraints on type variables
|
||||
-- across a decl's constructors.
|
||||
|
@ -1,4 +1,4 @@
|
||||
```unison
|
||||
```unison:error
|
||||
structural type Foo f
|
||||
= Foo (f ())
|
||||
unique type Baz = Baz (Foo Bar)
|
||||
|
@ -10,25 +10,9 @@ unique type Bar
|
||||
```ucm
|
||||
|
||||
Kind mismatch arising from
|
||||
5 | unique type Bar
|
||||
6 | = Bar Baz
|
||||
3 | unique type Baz = Baz (Foo Bar)
|
||||
|
||||
Expected kind: Type
|
||||
Given kind: Type -> Type
|
||||
Foo expects an argument of kind: Type -> Type; however, it
|
||||
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