Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,262
    • Issues 4,262
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 419
    • Merge Requests 419
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9091

Closed
Open
Opened May 08, 2014 by Andres Löh@kosmikusReporter

print and/or apply constraints when showing info for typed holes

Typed holes are fantastic already, but could be even better. Consider the following three examples:

Example 1

f :: Eq a => a -> a -> Bool
f x y = _

GHC-7.8.2 shows:

    Found hole ‘_’ with type: Bool
    Relevant bindings include
      y :: a (bound at THC.hs:4:5)
      x :: a (bound at THC.hs:4:3)
      f :: a -> a -> Bool (bound at THC.hs:4:1)
    In the expression: _
    In an equation for ‘f’: f x y = _

GHC additionally knows that Eq a holds. It would be great if it would print that, too.

Example 2

g :: (forall a. Eq a => a -> Bool) -> Bool
g f = f _ 

GHC-7.8.2 shows:

    Found hole ‘_’ with type: a0
    Where: ‘a0’ is an ambiguous type variable
    Relevant bindings include
      f :: forall a. Eq a => a -> Bool (bound at THC.hs:7:3)
      g :: (forall a. Eq a => a -> Bool) -> Bool (bound at THC.hs:7:1)
    In the first argument of ‘f’, namely ‘_’
    In the expression: f _
    In an equation for ‘g’: g f = f _

GHC additionally knows the Eq a0 must hold. It would be nice if it could indicate that.

Example 3

data X a where
  Y :: X Int

h :: X a -> a -> a
h Y x = _

GHC-7.8.2 shows:

    Found hole ‘_’ with type: Int
    Relevant bindings include
      x :: a (bound at THC.hs:13:5)
      h :: X a -> a -> a (bound at THC.hs:13:1)
    In the expression: _
    In an equation for ‘h’: h Y x = _

Interestingly, GHC shows that we have to produce an Int. Unfortunately, it shows that x is of type a. GHC additionally knows that a ~ Int. It would be nice if GHC could either apply the constraint to show that x :: Int or at least show the constraint.

Trac metadata
Trac field Value
Version 7.8.2
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#9091