[GHC] #12374: Type holes show incorrect type in GHCi

#12374: Type holes show incorrect type in GHCi -------------------------------------+------------------------------------- Reporter: crockeea | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect Unknown/Multiple | warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: 9479, 9091 Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- In a fresh GHCi: {{{
show _
<interactive>:7:6: error: • Found hole: _h :: () 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 ‘it’: it = show _h • Relevant bindings include it :: String (bound at <interactive>:7:1) }}} This seems wrong: the type of the hole is `_h :: Show a0 => a0`, not `_h :: ()`. On a related note, should this be reporting two errors (one for the hole, one for the constraint) as in #9479? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12374 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12374: Type holes show incorrect type in GHCi -------------------------------------+------------------------------------- Reporter: crockeea | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: 9479, 9091 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => invalid Comment: GHCi has type-class defaulting rules, described [http://downloads.haskell.org/~ghc/master/users-guide/ghci.html#type- defaulting-in-ghci here in the manual]. I think that's all that is happening here, so it's working as specified. Maybe the specification isn't right, but defaulting `Show` to `()` was driven by examples like {{{
show [] }}} I'll close as invalid for now.
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12374#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12374: Type holes show incorrect type in GHCi -------------------------------------+------------------------------------- Reporter: crockeea | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: 9479, 9091 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): Without defaulting {{{ GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help defaulLoaded GHCi configuration from /home/baldur/.ghci ghci> default () ghci> show _ <interactive>:2:1: 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 a => Show (ZipList a) -- Defined in ‘Control.Applicative’ instance Show a => Show (Down a) -- Defined in ‘Data.Ord’ instance Show CallStack -- Defined in ‘GHC.Show’ ...plus 28 others ...plus 77 instances involving out-of-scope types (use -fprint-potential-instances to see them all) • In the expression: show _ In an equation for ‘it’: it = show _ <interactive>:2:6: error: • Found hole: _ :: a0 Where: ‘a0’ is an ambiguous type variable • In the first argument of ‘show’, namely ‘_’ In the expression: show _ In an equation for ‘it’: it = show _ • Relevant bindings include it :: String (bound at <interactive>:2:1) ghci> }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12374#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC