Skip to content

Add new errors from polykinds branch #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions errors/CycleInKindDeclaration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# `CycleInKindDeclaration` Error

## Cause

A top-level kind signature is declared in a way that would incur a dependency on itself.

## Fix

- A kind signature cannot depend on itself.
- Check the kind signature for any types mentioned in the kind signature.
10 changes: 10 additions & 0 deletions errors/InternalCompilerError.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# `InternalCompilerError` Error

## Cause

An internal compiler invariant was violated, aborting compilation. This is a
defect in the compiler.

## Fix

- Report the error to [the PureScript compiler repo](https://github.com/purescript/purescript).
16 changes: 16 additions & 0 deletions errors/OrphanKindDeclaration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# `OrphanKindDeclaration` Error

## Example

```purescript
data Proxy :: forall k. k -> Type
```

## Cause

A top-level kind signature is provided but not immediately followed by it's declaration.

## Fix

- Check that you've provided the appropriate `data`, `newtype`, `type`, or `class` declaration.
- Check that the keywords match.
14 changes: 14 additions & 0 deletions errors/QuantificationCheckFailureInKind.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# `QuantificationCheckFailureInKind` Error

## Cause

This error occurs when implicitly generalizing the kind of a `forall`
quantified type variable would result in an ill-scoped generalization. The
compiler always orders implicitly generalized kind variables first within a
`forall` quantifier. It's possible to introduce a dependency on an explicit
type variable in an inferred kind such that generalizing that kind would
place it out of the scope of its dependency.

## Fix

- Generalize and order the kind explicitly
43 changes: 43 additions & 0 deletions errors/QuantificationCheckFailureInType.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# `QuantificationCheckFailureInType` Error

## Example

```purescript
data Proxy :: forall k. k -> Type
data Proxy a = Proxy

type SomeProxy = forall a. Proxy a
```

## Cause

This error occurs when the compiler tries to implicitly generalize a kind but
there are multiple ways in which it could be quantified. This most often
happens in the right-hand-side of type synonyms. In the above example, what
is the kind of the type variable `a`?

```purescript
type SomeProxy = forall (a :: ???). Proxy a
```

We know that it could potentially be anything per the kind signature of
`Proxy`, but how should it be quantified?

```purescript
-- Quantifying in the forall.
type SomeProxy = forall k (a :: k). Proxy a

-- Quantifying in a kind signature
type SomeProxy :: forall k. Type
type SomeProxy = forall (a :: k). Proxy a

-- Quantify explicitly with an argument to the synonym
type SomeProxy k = forall (a :: k). Proxy a
```

The only places the compiler considers unambiguous are within top-level type
and kind signatures.

## Fix

- Explicitly quantify the kind in the way most appropriate for your use case.
17 changes: 17 additions & 0 deletions errors/UnsupportedTypeInKind.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# `UnsupportedTypeInKind` Error

## Example

```purescript
foreign import data Bad :: SomeConstraint => Type
```

## Cause

Not all types are valid in a kind signature. Particularly constraint arrows
(`=>`) are disallowed since they only make sense for term-level constraint
dependencies.

## Fix

- Only use types that are valid in kinds.
9 changes: 9 additions & 0 deletions errors/VisibleQuantificationCheckFailureInType.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# `VisibleQuantificationCheckFailureInType` Error

## Cause

Kinds are annotated in such a way that they require a visible dependent quantifier.

## Fix

- Visible dependent quantification is not supported.
11 changes: 11 additions & 0 deletions errors/WarningParsingModule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `WarningParsingModule` Warning

## Cause

The language parser found deprecated (but still valid) syntax. Your program
still compiles fine, but will be rejected in the future.

## Fix

- Follow the instructions in the warning, or apply the suggested fix
automatically if one is provided.