v0.15.13
New features:
-
Replace
UnusableDeclaration
with updatedNoInstanceFound
(#4513 by @JordanMartinez)Previously, the following type class would be invalid
because there was no way for the compiler to infer
which type class instance to select because
the type variable in the class heada
was
not mentioned inbar
's type signature:class Foo a where bar :: Int
The recently-added visible type applications (VTAs)
can now be used to guide the compiler in such cases:class Foo a where bar :: Int instance Foo String where bar = 0 someInt = bar @String -- use the `String` instance
Without VTAs, the compiler
will still produce anInstanceNotFound
error, but this error
has been updated to note which type variables in the class head
can only be disambiguated via visible type applications.
Given the following codeclass Single tyVarDoesNotAppearInBody where useSingle :: Int single :: Int single = useSingle
The error reported for
useSingle
will be:No type class instance was found for Main.Single t0 The instance head contains unknown type variables. Note: The following type class members found in the expression require visible type applications to be unambiguous (e.g. tyClassMember @Int). Main.useSingle tyNotAppearInBody
For a multiparameter typeclass with functional dependencies...
class MultiFdBidi a b | a -> b, b -> a where useMultiFdBidi :: Int multiFdBidi :: Int multiFdBidi = useMultiFdBidi
...the "Note" part is updated to read
Note: The following type class members found in the expression require visible type applications to be unambiguous (e.g. tyClassMember @Int). Main.useMultiFdBidi One of the following sets of type variables: a b
Bugfixes:
- Fix parsing bug where
@var
was allowed in type class head (#4523 by @JordanMartinez)