Skip to content

Commit 3226216

Browse files
authored
Add new errors from polykinds branch (#300)
1 parent 6b9cddd commit 3226216

8 files changed

+130
-0
lines changed

errors/CycleInKindDeclaration.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# `CycleInKindDeclaration` Error
2+
3+
## Cause
4+
5+
A top-level kind signature is declared in a way that would incur a dependency on itself.
6+
7+
## Fix
8+
9+
- A kind signature cannot depend on itself.
10+
- Check the kind signature for any types mentioned in the kind signature.

errors/InternalCompilerError.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# `InternalCompilerError` Error
2+
3+
## Cause
4+
5+
An internal compiler invariant was violated, aborting compilation. This is a
6+
defect in the compiler.
7+
8+
## Fix
9+
10+
- Report the error to [the PureScript compiler repo](https://github.com/purescript/purescript).

errors/OrphanKindDeclaration.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# `OrphanKindDeclaration` Error
2+
3+
## Example
4+
5+
```purescript
6+
data Proxy :: forall k. k -> Type
7+
```
8+
9+
## Cause
10+
11+
A top-level kind signature is provided but not immediately followed by it's declaration.
12+
13+
## Fix
14+
15+
- Check that you've provided the appropriate `data`, `newtype`, `type`, or `class` declaration.
16+
- Check that the keywords match.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# `QuantificationCheckFailureInKind` Error
2+
3+
## Cause
4+
5+
This error occurs when implicitly generalizing the kind of a `forall`
6+
quantified type variable would result in an ill-scoped generalization. The
7+
compiler always orders implicitly generalized kind variables first within a
8+
`forall` quantifier. It's possible to introduce a dependency on an explicit
9+
type variable in an inferred kind such that generalizing that kind would
10+
place it out of the scope of its dependency.
11+
12+
## Fix
13+
14+
- Generalize and order the kind explicitly
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# `QuantificationCheckFailureInType` Error
2+
3+
## Example
4+
5+
```purescript
6+
data Proxy :: forall k. k -> Type
7+
data Proxy a = Proxy
8+
9+
type SomeProxy = forall a. Proxy a
10+
```
11+
12+
## Cause
13+
14+
This error occurs when the compiler tries to implicitly generalize a kind but
15+
there are multiple ways in which it could be quantified. This most often
16+
happens in the right-hand-side of type synonyms. In the above example, what
17+
is the kind of the type variable `a`?
18+
19+
```purescript
20+
type SomeProxy = forall (a :: ???). Proxy a
21+
```
22+
23+
We know that it could potentially be anything per the kind signature of
24+
`Proxy`, but how should it be quantified?
25+
26+
```purescript
27+
-- Quantifying in the forall.
28+
type SomeProxy = forall k (a :: k). Proxy a
29+
30+
-- Quantifying in a kind signature
31+
type SomeProxy :: forall k. Type
32+
type SomeProxy = forall (a :: k). Proxy a
33+
34+
-- Quantify explicitly with an argument to the synonym
35+
type SomeProxy k = forall (a :: k). Proxy a
36+
```
37+
38+
The only places the compiler considers unambiguous are within top-level type
39+
and kind signatures.
40+
41+
## Fix
42+
43+
- Explicitly quantify the kind in the way most appropriate for your use case.

errors/UnsupportedTypeInKind.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# `UnsupportedTypeInKind` Error
2+
3+
## Example
4+
5+
```purescript
6+
foreign import data Bad :: SomeConstraint => Type
7+
```
8+
9+
## Cause
10+
11+
Not all types are valid in a kind signature. Particularly constraint arrows
12+
(`=>`) are disallowed since they only make sense for term-level constraint
13+
dependencies.
14+
15+
## Fix
16+
17+
- Only use types that are valid in kinds.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# `VisibleQuantificationCheckFailureInType` Error
2+
3+
## Cause
4+
5+
Kinds are annotated in such a way that they require a visible dependent quantifier.
6+
7+
## Fix
8+
9+
- Visible dependent quantification is not supported.

errors/WarningParsingModule.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# `WarningParsingModule` Warning
2+
3+
## Cause
4+
5+
The language parser found deprecated (but still valid) syntax. Your program
6+
still compiles fine, but will be rejected in the future.
7+
8+
## Fix
9+
10+
- Follow the instructions in the warning, or apply the suggested fix
11+
automatically if one is provided.

0 commit comments

Comments
 (0)