[GHC] #9613: when giving an error "No instance for C (a -> b)", suggest that a function may be underapplied

#9613: when giving an error "No instance for C (a -> b)", suggest that a function may be underapplied -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Operating System: Keywords: | Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: Difficulty: Unknown | None/Unknown Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Suggestion of ibotty here: http://www.reddit.com/r/haskell/comments/2go92u/beginner_error_messages_in_c... {{{ Prelude> print length <interactive>:2:1: No instance for (Show ([a0] -> Int)) arising from a use of ‘print’ but there is an instance for (Show Int); maybe you omitted an argument to ‘length’ of type [a0]? In the expression: print length In an equation for ‘it’: it = print length }}} I guess the trickiest part will be figuring out what function is underapplied. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9613 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9613: when giving an error "No instance for C (a -> b)", suggest that a function may be underapplied -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: (Type checker) | Architecture: Unknown/Multiple Resolution: | Difficulty: Unknown Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by MikeIzbicki): This is roughly equivalent to the patch I suggest in: https://phabricator.haskell.org/D201 (TcErrors.lhs, line 1094ish). The difference is that my patch doesn't suggest the underapplied function name or the instances that do exist. It seems pretty straightforward to mention the existing instance, so I'll try to add that. I'm pretty sure it's in general impossible to name the argument. For example, in `show (length . head . tail)` which function do you say is underapplied? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9613#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9613: when giving an error "No instance for C (a -> b)", suggest that a function may be underapplied -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: (Type checker) | Architecture: Unknown/Multiple Resolution: | Difficulty: Unknown Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by ibotty): the underapplied function is {{{ length . head . tail }}} it is missing an argument of type {{{[[a0]]}}}. am i missing things? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9613#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9613: when giving an error "No instance for C (a -> b)", suggest that a function may be underapplied -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thomie): The message is now (ghc-7.10.2): {{{ Prelude> print length <interactive>:2:1: No instance for (Show (t0 a0 -> Int)) (maybe you haven't applied enough arguments to a function?) arising from a use of ‘print’ In the expression: print length In an equation for ‘it’: it = print length }}} In commit bc2289e13d9586be087bd8136943dc35a0130c88: {{{ Author: Mike Izbicki <> Date: Wed Nov 19 18:29:37 2014 -0600 ghc generates more user-friendly error messages Test Plan: Compiled ghc fine. Opened ghci and fed it invalid code. It gave the improved error messages in response. Reviewers: austin Subscribers: thomie, simonpj, spacekitteh, rwbarton, simonmar, carter Differential Revision: https://phabricator.haskell.org/D201 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9613#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9613: when giving an error "No instance for C (a -> b)", suggest that a function may be underapplied -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Resolution: fixed | Keywords: 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/9613#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC