2023-09-20 22:20:53 +03:00
|
|
|
## A type param cannot have conflicting kind constraints within a single decl
|
|
|
|
|
|
|
|
conflicting constraints on the kind of `a` in a product
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
unique type T a = T a (a Nat)
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
Kind mismatch arising from
|
2023-09-21 20:49:30 +03:00
|
|
|
1 | unique type T a = T a (a Nat)
|
|
|
|
|
|
|
|
a doesn't expect an argument; however, it is applied to Nat.
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
conflicting constraints on the kind of `a` in a sum
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
unique type T a
|
|
|
|
= Star a
|
|
|
|
| StarStar (a Nat)
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
Kind mismatch arising from
|
2023-09-21 20:49:30 +03:00
|
|
|
3 | | StarStar (a Nat)
|
|
|
|
|
|
|
|
a doesn't expect an argument; however, it is applied to Nat.
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
## Kinds are inferred by decl component
|
|
|
|
|
|
|
|
Successfully infer `a` in `Ping a` to be of kind `* -> *` by
|
|
|
|
inspecting its component-mate `Pong`.
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
unique type Ping a = Ping Pong
|
|
|
|
unique type Pong = Pong (Ping Optional)
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These new definitions are ok to `add`:
|
|
|
|
|
2024-01-04 11:42:12 +03:00
|
|
|
type Ping a
|
|
|
|
type Pong
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
Catch the conflict on the kind of `a` in `Ping a`. `Ping` restricts
|
|
|
|
`a` to `*`, whereas `Pong` restricts `a` to `* -> *`.
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
unique type Ping a = Ping a Pong
|
|
|
|
unique type Pong = Pong (Ping Optional)
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
Kind mismatch arising from
|
2023-09-21 20:49:30 +03:00
|
|
|
1 | unique type Ping a = Ping a Pong
|
|
|
|
|
2023-10-04 19:45:30 +03:00
|
|
|
The arrow type (->) expects arguments of kind Type; however,
|
|
|
|
it is applied to a which has kind: Type -> Type.
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
Successful example between mutually recursive type and ability
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
unique type Ping a = Ping (a Nat -> {Pong Nat} ())
|
|
|
|
unique ability Pong a where
|
|
|
|
pong : Ping Optional -> ()
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These new definitions are ok to `add`:
|
|
|
|
|
2024-01-04 11:42:12 +03:00
|
|
|
type Ping a
|
|
|
|
ability Pong a
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
Catch conflict between mutually recursive type and ability
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
unique type Ping a = Ping (a -> {Pong Nat} ())
|
|
|
|
unique ability Pong a where
|
|
|
|
pong : Ping Optional -> ()
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
Kind mismatch arising from
|
2023-09-21 20:49:30 +03:00
|
|
|
3 | pong : Ping Optional -> ()
|
|
|
|
|
2023-10-04 19:45:30 +03:00
|
|
|
Ping expects an argument of kind: Type; however, it is
|
|
|
|
applied to Optional which has kind: Type -> Type.
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
Consistent instantiation of `T`'s `a` parameter in `S`
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
unique type T a = T a
|
|
|
|
|
|
|
|
unique type S = S (T Nat)
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These new definitions are ok to `add`:
|
|
|
|
|
2024-01-04 11:42:12 +03:00
|
|
|
type S
|
|
|
|
type T a
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-10-27 17:37:08 +03:00
|
|
|
```
|
2023-10-30 16:56:05 +03:00
|
|
|
Delay kind defaulting until all components are processed. Here `S`
|
|
|
|
constrains the kind of `T`'s `a` parameter, although `S` is not in
|
|
|
|
the same component as `T`.
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-10-27 17:37:08 +03:00
|
|
|
unique type T a = T
|
|
|
|
|
|
|
|
unique type S = S (T Optional)
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-10-27 17:37:08 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-10-27 17:38:22 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These new definitions are ok to `add`:
|
2023-10-27 17:37:08 +03:00
|
|
|
|
2024-01-04 11:42:12 +03:00
|
|
|
type S
|
|
|
|
type T a
|
2023-10-27 17:37:08 +03:00
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
```
|
|
|
|
Catch invalid instantiation of `T`'s `a` parameter in `S`
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
unique type T a = T a
|
|
|
|
|
|
|
|
unique type S = S (T Optional)
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
Kind mismatch arising from
|
2023-09-21 20:49:30 +03:00
|
|
|
3 | unique type S = S (T Optional)
|
|
|
|
|
2023-10-04 19:45:30 +03:00
|
|
|
T expects an argument of kind: Type; however, it is applied
|
|
|
|
to Optional which has kind: Type -> Type.
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
## Checking annotations
|
|
|
|
|
|
|
|
Catch kind error in type annotation
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
test : Nat Nat
|
|
|
|
test = 0
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
Kind mismatch arising from
|
2023-09-21 20:49:30 +03:00
|
|
|
1 | test : Nat Nat
|
|
|
|
|
|
|
|
Nat doesn't expect an argument; however, it is applied to
|
|
|
|
Nat.
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
Catch kind error in annotation example 2
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
test : Optional -> ()
|
|
|
|
test _ = ()
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
Kind mismatch arising from
|
2023-09-21 20:49:30 +03:00
|
|
|
1 | test : Optional -> ()
|
|
|
|
|
2023-10-04 19:45:30 +03:00
|
|
|
The arrow type (->) expects arguments of kind Type; however,
|
|
|
|
it is applied to Optional which has kind: Type -> Type.
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
Catch kind error in annotation example 3
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
unique type T a = T (a Nat)
|
|
|
|
|
|
|
|
test : T Nat -> ()
|
|
|
|
test _ = ()
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
Kind mismatch arising from
|
2023-09-21 20:49:30 +03:00
|
|
|
3 | test : T Nat -> ()
|
|
|
|
|
2023-10-04 19:45:30 +03:00
|
|
|
T expects an argument of kind: Type -> Type; however, it is
|
|
|
|
applied to Nat which has kind: Type.
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
Catch kind error in scoped type variable annotation
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
unique type StarStar a = StarStar (a Nat)
|
|
|
|
unique type Star a = Star a
|
|
|
|
|
|
|
|
test : StarStar a -> ()
|
|
|
|
test _ =
|
|
|
|
buggo : Star a
|
|
|
|
buggo = bug ""
|
|
|
|
()
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
Kind mismatch arising from
|
2023-09-21 20:49:30 +03:00
|
|
|
6 | buggo : Star a
|
|
|
|
|
2023-10-04 19:45:30 +03:00
|
|
|
Star expects an argument of kind: Type; however, it is
|
|
|
|
applied to a which has kind: Type -> Type.
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
## Effect/type mismatch
|
|
|
|
|
|
|
|
Effects appearing where types are expected
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
unique ability Foo where
|
|
|
|
foo : ()
|
|
|
|
|
|
|
|
test : Foo -> ()
|
|
|
|
test _ = ()
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
Kind mismatch arising from
|
2023-09-21 20:49:30 +03:00
|
|
|
4 | test : Foo -> ()
|
|
|
|
|
2023-10-04 19:45:30 +03:00
|
|
|
The arrow type (->) expects arguments of kind Type; however,
|
|
|
|
it is applied to Foo which has kind: Ability.
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
Types appearing where effects are expected
|
2024-07-10 17:46:18 +03:00
|
|
|
|
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
test : {Nat} ()
|
|
|
|
test _ = ()
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
Kind mismatch arising from
|
2023-09-21 20:49:30 +03:00
|
|
|
1 | test : {Nat} ()
|
|
|
|
|
|
|
|
An ability list must consist solely of abilities; however,
|
2023-10-04 19:45:30 +03:00
|
|
|
this list contains Nat which has kind Type. Abilities are of
|
|
|
|
kind Ability.
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
## Cyclic kinds
|
|
|
|
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2023-09-20 22:20:53 +03:00
|
|
|
unique type T a = T (a a)
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-20 22:20:53 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-20 22:20:53 +03:00
|
|
|
Cannot construct infinite kind
|
|
|
|
1 | unique type T a = T (a a)
|
|
|
|
|
2023-09-21 20:49:30 +03:00
|
|
|
The above application constrains the kind of a to be
|
2023-10-04 19:45:30 +03:00
|
|
|
infinite, generated by the constraint k = k -> Type where k
|
|
|
|
is the kind of a.
|
2023-09-21 20:49:30 +03:00
|
|
|
|
|
|
|
```
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2023-09-21 20:49:30 +03:00
|
|
|
unique type T a b = T (a b) (b a)
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-21 20:49:30 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-21 20:49:30 +03:00
|
|
|
Cannot construct infinite kind
|
|
|
|
1 | unique type T a b = T (a b) (b a)
|
|
|
|
|
|
|
|
The above application constrains the kind of b to be
|
2023-10-04 19:45:30 +03:00
|
|
|
infinite, generated by the constraint
|
|
|
|
k = (k -> Type) -> Type where k is the kind of b.
|
2023-09-21 20:49:30 +03:00
|
|
|
|
|
|
|
```
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2023-09-21 20:49:30 +03:00
|
|
|
unique type Ping a = Ping (a Pong)
|
|
|
|
unique type Pong a = Pong (a Ping)
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2023-09-21 20:49:30 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2023-09-21 20:49:30 +03:00
|
|
|
Cannot construct infinite kind
|
|
|
|
1 | unique type Ping a = Ping (a Pong)
|
|
|
|
|
|
|
|
The above application constrains the kind of a to be
|
|
|
|
infinite, generated by the constraint
|
2023-10-04 19:45:30 +03:00
|
|
|
k = (((k -> Type) -> Type) -> Type) -> Type where k is the
|
|
|
|
kind of a.
|
2023-09-20 22:20:53 +03:00
|
|
|
|
|
|
|
```
|