From b62c8086fe5ca4b00dbfafae40f833a7c305fce0 Mon Sep 17 00:00:00 2001 From: Nathan Faubion Date: Sat, 29 Feb 2020 08:38:56 -0800 Subject: [PATCH] Add new errors from polykinds branch --- errors/CycleInKindDeclaration.md | 10 +++++ errors/InternalCompilerError.md | 10 +++++ errors/OrphanKindDeclaration.md | 16 +++++++ errors/QuantificationCheckFailureInKind.md | 14 ++++++ errors/QuantificationCheckFailureInType.md | 43 +++++++++++++++++++ errors/UnsupportedTypeInKind.md | 17 ++++++++ ...VisibleQuantificationCheckFailureInType.md | 9 ++++ errors/WarningParsingModule.md | 11 +++++ 8 files changed, 130 insertions(+) create mode 100644 errors/CycleInKindDeclaration.md create mode 100644 errors/InternalCompilerError.md create mode 100644 errors/OrphanKindDeclaration.md create mode 100644 errors/QuantificationCheckFailureInKind.md create mode 100644 errors/QuantificationCheckFailureInType.md create mode 100644 errors/UnsupportedTypeInKind.md create mode 100644 errors/VisibleQuantificationCheckFailureInType.md create mode 100644 errors/WarningParsingModule.md diff --git a/errors/CycleInKindDeclaration.md b/errors/CycleInKindDeclaration.md new file mode 100644 index 00000000..c48c22e7 --- /dev/null +++ b/errors/CycleInKindDeclaration.md @@ -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. diff --git a/errors/InternalCompilerError.md b/errors/InternalCompilerError.md new file mode 100644 index 00000000..a43d2474 --- /dev/null +++ b/errors/InternalCompilerError.md @@ -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). diff --git a/errors/OrphanKindDeclaration.md b/errors/OrphanKindDeclaration.md new file mode 100644 index 00000000..1d63f145 --- /dev/null +++ b/errors/OrphanKindDeclaration.md @@ -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. diff --git a/errors/QuantificationCheckFailureInKind.md b/errors/QuantificationCheckFailureInKind.md new file mode 100644 index 00000000..de859e8f --- /dev/null +++ b/errors/QuantificationCheckFailureInKind.md @@ -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 diff --git a/errors/QuantificationCheckFailureInType.md b/errors/QuantificationCheckFailureInType.md new file mode 100644 index 00000000..734954c0 --- /dev/null +++ b/errors/QuantificationCheckFailureInType.md @@ -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. diff --git a/errors/UnsupportedTypeInKind.md b/errors/UnsupportedTypeInKind.md new file mode 100644 index 00000000..739c4a42 --- /dev/null +++ b/errors/UnsupportedTypeInKind.md @@ -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. diff --git a/errors/VisibleQuantificationCheckFailureInType.md b/errors/VisibleQuantificationCheckFailureInType.md new file mode 100644 index 00000000..3143f375 --- /dev/null +++ b/errors/VisibleQuantificationCheckFailureInType.md @@ -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. diff --git a/errors/WarningParsingModule.md b/errors/WarningParsingModule.md new file mode 100644 index 00000000..322f6700 --- /dev/null +++ b/errors/WarningParsingModule.md @@ -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.