Skip to content

Include more information about why constraints are missing #1866

@hdgarrood

Description

@hdgarrood

Given this code:

> let f x y = x + x * y
Error found:
in module $PSCI
at  line 1, column 5 - line 1, column 21
  No type class instance was found for
    Prelude.Semiring _0
  The instance head contains unknown type variables. Consider adding a type annotation.
in value declaration f
where _0 is an unknown type

the error message does the job well enough, I think.

However, for functions with large bodies, it can be difficult to track down why the constraint is required - which is a problem if you weren't intending your function to have that constraint at all. GHC includes a little extra information for missing instance errors, something like this:

    No instance for (Num a1) arising from a use of ‘+’
    In the expression: x + x * y

Could psc do this too?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions