[GHC] #9479: Report required constraints when reporting the type of a hole

#9479: Report required constraints when reporting the type of a hole -------------------------------------+------------------------------------- Reporter: dominiquedevriese | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Operating System: Keywords: holes | Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: Difficulty: Unknown | None/Unknown Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- For the following code {{{ module Test where test :: String test = show _h }}} GHC currently reports: {{{ Found hole ‘_h’ with type: a0 Where: ‘a0’ is an ambiguous type variable Relevant bindings include test :: String (bound at /tmp/Test.hs:4:1) In the first argument of ‘show’, namely ‘_h’ In the expression: show _h In an equation for ‘test’: test = show _h }}} It correctly does not report the lack of a `Show _a` instance as a separate type error. However, it would be useful if the report containing the type of the hole would also contain the constraints that apply to its type. Something like: {{{ Found hole ‘_h’ with type: a0 Where: ‘a0’ is an ambiguous type variable Applicable constraints: Show a0 Relevant bindings include test :: String (bound at /tmp/Test.hs:4:1) In the first argument of ‘show’, namely ‘_h’ In the expression: show _h In an equation for ‘test’: test = show _h }}} I am explicitly *not* suggesting to report a type like `Show a0 => a0` for the hole, because that might mistakenly suggest that we are looking for a value of type `forall a0. Show a0 => a0`, which we are not. A possible alternative is to use an imaginary exists type like `exists a0. Show a0 => a0` but that's probably just even more confusing. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9479 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9479: Report required constraints when reporting the type of a hole -------------------------------------+------------------------------------- Reporter: | Owner: dominiquedevriese | Status: new Type: feature | Milestone: request | Version: 7.8.3 Priority: low | Keywords: holes Component: Compiler | Architecture: Unknown/Multiple (Type checker) | Difficulty: Unknown Resolution: | Blocked By: Operating System: | Related Tickets: Unknown/Multiple | Type of failure: | None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by dominiquedevriese): Note: this report was triggered by the following StackOverflow question: http://stackoverflow.com/questions/23028124/is-there-a-way-to-make-ghc- provide-the-type-class-constraints-of-typed-holes -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9479#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9479: Report required constraints when reporting the type of a hole -------------------------------------+------------------------------------- Reporter: | Owner: dominiquedevriese | Status: new Type: feature | Milestone: request | Version: 7.8.3 Priority: low | Keywords: holes Component: Compiler | Architecture: Unknown/Multiple (Type checker) | Difficulty: Unknown Resolution: | Blocked By: Operating System: | Related Tickets: Unknown/Multiple | Type of failure: | None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by mentheta): How can I watch this ticket for activity? I am interested in future development related to this feature. I'm sorry if this "meta question" is out of place, but I couldn't find a "watch button" either on this page, or for trac in general. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9479#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9479: Report required constraints when reporting the type of a hole -------------------------------------+------------------------------------- Reporter: | Owner: dominiquedevriese | Status: new Type: feature | Milestone: request | Version: 7.8.3 Priority: low | Keywords: holes Component: Compiler | Architecture: Unknown/Multiple (Type checker) | Difficulty: Unknown Resolution: | Blocked By: Operating System: | Related Tickets: Unknown/Multiple | Type of failure: | None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): Open up the "Modify Ticket" option near the comment box and add your email to the "Cc" field. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9479#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9479: Report required constraints when reporting the type of a hole -------------------------------------+------------------------------------- Reporter: | Owner: dominiquedevriese | Status: new Type: feature | Milestone: request | Version: 7.8.3 Priority: low | Keywords: holes Component: Compiler | Architecture: Unknown/Multiple (Type checker) | Difficulty: Unknown Resolution: | Blocked By: Operating System: | Related Tickets: Unknown/Multiple | Type of failure: | None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): I think this would be fairly easy to implement, and I talked to someone at ICFP who plans to do so. Happy to offer guidance. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9479#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9479: Report required constraints when reporting the type of a hole -------------------------------------+------------------------------------- Reporter: | Owner: dominiquedevriese | Status: new Type: feature | Milestone: request | Version: 7.8.3 Priority: low | Keywords: holes Component: Compiler | Architecture: Unknown/Multiple (Type checker) | Difficulty: Unknown Resolution: | Blocked By: Operating System: | Related Tickets: Unknown/Multiple | Type of failure: | None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by phadej): With `-fdefer-type-errors` GHC (both 7.8 and 7.10) tries a bit longer and finds the missing instance: {{{ [1 of 1] Compiling Test ( /Users/ogre/show.hs, /Users/ogre/show.o ) /Users/ogre/show.hs:4:8: Warning: No instance for (Show a0) arising from a use of ‘show’ The type variable ‘a0’ is ambiguous Note: there are several potential instances: instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’ instance Show Ordering -- Defined in ‘GHC.Show’ instance Show Integer -- Defined in ‘GHC.Show’ ...plus 22 others In the expression: show _h In an equation for ‘test’: test = show _h /Users/ogre/show.hs:4:13: Warning: Found hole ‘_h’ with type: a0 Where: ‘a0’ is an ambiguous type variable Relevant bindings include test :: String (bound at /Users/ogre/show.hs:4:1) In the first argument of ‘show’, namely ‘_h’ In the expression: show _h In an equation for ‘test’: test = show _h }}} So should we make holeReporter to try to find //Dicts// errors too, if `-fdefer-type-errors` is not set? IMHO the //No instance// error is what we need here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9479#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9479: Report required constraints when reporting the type of a hole -------------------------------------+------------------------------------- Reporter: | Owner: dominiquedevriese | Status: new Type: feature request | Milestone: Priority: low | Version: 7.8.3 Component: Compiler (Type | Keywords: holes checker) | Architecture: Resolution: | Unknown/Multiple Operating System: Unknown/Multiple | Test Case: Type of failure: None/Unknown | Blocking: Blocked By: | Differential Revisions: Related Tickets: | -------------------------------------+------------------------------------- Changes (by ekmett): * cc: ekmett (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9479#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9479: Report required constraints when reporting the type of a hole -------------------------------------+------------------------------------- Reporter: | Owner: dominiquedevriese | Type: feature request | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.8.3 checker) | Resolution: | Keywords: holes Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * priority: low => normal * milestone: => 8.0.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9479#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9479: Report required constraints when reporting the type of a hole -------------------------------------+------------------------------------- Reporter: | Owner: dominiquedevriese | Type: feature request | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.8.3 checker) | Resolution: | Keywords: holes Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie): This is fixed in HEAD. {{{ $ ghc-7.11.20151213 Test.hs [1 of 1] Compiling Test ( Test.hs, Test.o ) Test.hs:4:8: error: • Ambiguous type variable ‘a0’ arising from a use of ‘show’ prevents the constraint ‘(Show a0)’ from being solved. Probable fix: use a type annotation to specify what ‘a0’ should be. These potential instances exist: instance Show Module -- Defined in ‘GHC.Show’ instance Show Ordering -- Defined in ‘GHC.Show’ instance Show TrName -- Defined in ‘GHC.Show’ ...plus 25 others (use -fprint-potential-instances to see them all) • In the expression: show _h In an equation for ‘test’: test = show _h Test.hs:4:13: error: • Found hole: _h :: a0 Where: ‘a0’ is an ambiguous type variable Or perhaps ‘_h’ is mis-spelled, or not in scope • In the first argument of ‘show’, namely ‘_h’ In the expression: show _h In an equation for ‘test’: test = show _h • Relevant bindings include test :: String (bound at Test.hs:4:1) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9479#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9479: Report required constraints when reporting the type of a hole -------------------------------------+------------------------------------- Reporter: | Owner: dominiquedevriese | Type: feature request | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.8.3 checker) | Resolution: fixed | Keywords: holes Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9479#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9479: Report required constraints when reporting the type of a hole -------------------------------------+------------------------------------- Reporter: | Owner: (none) dominiquedevriese | Type: feature request | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.8.3 checker) | Resolution: fixed | Keywords: TypedHoles Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: holes => TypedHoles -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9479#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9479: Report required constraints when reporting the type of a hole -------------------------------------+------------------------------------- Reporter: | Owner: (none) dominiquedevriese | Type: feature request | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.8.3 checker) | Resolution: fixed | Keywords: TypedHoles Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9091 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * related: => #9091 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9479#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC