Skip to content

Add class/context information to typed hole relevant bindings

GHC's typed hole messages don't currently include any known context information for relevant bindings. For example:

bar :: a ~ b => a -> b -> Int
bar x y = _

gets me

    Found hole ‘_’ with type: Int
    Relevant bindings include
      y :: b (bound at <interactive>:8:42)
      x :: a (bound at <interactive>:8:40)
      bar :: a -> b -> Int (bound at <interactive>:8:36)
    In the expression: _
    In an equation for ‘bar’: bar x y = _

The types a and b are not unified, and the a ~ b constraint is not shown.

foo :: Show a => a -> Int
foo x = _

gets me

    Found hole ‘_’ with type: Int
    Relevant bindings include
      x :: a (bound at <interactive>:4:36)
      foo :: a -> Int (bound at <interactive>:4:32)
    In the expression: _
    In an equation for ‘foo’: foo x = _

The Show constraint is lost.

What I want

I'd like context information for all type variables in known bindings, so I can see all the pieces available to help me fill in the hole.

Related ticket

In #9479 (closed), Dominique Devriese wants to see any constraints on an ambiguously-typed hole.

Trac metadata
Trac field Value
Version 7.10.2
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related #9479 (closed)
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information