[GHC] #10249: Suboptimal error message with deferred type errors

#10249: Suboptimal error message with deferred type errors -------------------------------------+------------------------------------- Reporter: | Owner: Iceland_jack | Status: new Type: feature | Milestone: request | Version: 7.10.1 Priority: normal | Operating System: Unknown/Multiple Component: GHCi | Type of failure: None/Unknown Keywords: | Blocked By: Architecture: | Related Tickets: Unknown/Multiple | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- {{{#!hs $ ghci -fdefer-type-errors -ignore-dot-ghci GHCi, version 7.10.0.20150316: http://www.haskell.org/ghc/ :? for help Prelude> _ <interactive>:2:1: Warning: Found hole ‘_’ with type: IO t0 Where: ‘t0’ is an ambiguous type variable In the first argument of ‘GHC.GHCi.ghciStepIO :: IO a_aly -> IO a_aly’, namely ‘_’ In a stmt of an interactive GHCi command: it <- GHC.GHCi.ghciStepIO :: IO a_aly -> IO a_aly _ *** Exception: <interactive>:2:1: Found hole ‘_’ with type: IO t0 Where: ‘t0’ is an ambiguous type variable In the first argument of ‘GHC.GHCi.ghciStepIO :: IO a_aly -> IO a_aly’, namely ‘_’ In a stmt of an interactive GHCi command: it <- GHC.GHCi.ghciStepIO :: IO a_aly -> IO a_aly _ (deferred type error) Prelude> }}} It should ideally not expose `ghciStepIO` to the user. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10249 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10249: Suboptimal error message with deferred type errors -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): Yes, that's true. Generally, GHC checks exactly what the user writes, but for GHCi it actually checks a synthesised expression wrapping what the user writes. This would not be difficult to fix; perhaps a bit fiddly. I'm happy to advise. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10249#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10249: Suboptimal error message with deferred type errors -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by monoidal): For what's worth you don't need deferred type errors to see `ghciStepIO`; `x <- 'a'` shows a type error with it as well. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10249#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10249: GHCi leaky abstraction: error message mentions `ghciStepIO` -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | 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): * type: feature request => bug -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10249#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10249: GHCi leaky abstraction: error message mentions `ghciStepIO` -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * failure: None/Unknown => Incorrect warning at compile-time * milestone: => 8.0.1 Old description:
{{{#!hs $ ghci -fdefer-type-errors -ignore-dot-ghci GHCi, version 7.10.0.20150316: http://www.haskell.org/ghc/ :? for help Prelude> _
<interactive>:2:1: Warning: Found hole ‘_’ with type: IO t0 Where: ‘t0’ is an ambiguous type variable In the first argument of ‘GHC.GHCi.ghciStepIO :: IO a_aly -> IO a_aly’, namely ‘_’ In a stmt of an interactive GHCi command: it <- GHC.GHCi.ghciStepIO :: IO a_aly -> IO a_aly _ *** Exception: <interactive>:2:1: Found hole ‘_’ with type: IO t0 Where: ‘t0’ is an ambiguous type variable In the first argument of ‘GHC.GHCi.ghciStepIO :: IO a_aly -> IO a_aly’, namely ‘_’ In a stmt of an interactive GHCi command: it <- GHC.GHCi.ghciStepIO :: IO a_aly -> IO a_aly _ (deferred type error) Prelude> }}}
It should ideally not expose `ghciStepIO` to the user.
New description: {{{ $ ghci -fdefer-type-errors -ignore-dot-ghci GHCi, version 7.10.0.20150316: http://www.haskell.org/ghc/ :? for help Prelude> _ <interactive>:2:1: Warning: Found hole ‘_’ with type: IO t0 Where: ‘t0’ is an ambiguous type variable In the first argument of ‘GHC.GHCi.ghciStepIO :: IO a_aly -> IO a_aly’, namely ‘_’ In a stmt of an interactive GHCi command: it <- GHC.GHCi.ghciStepIO :: IO a_aly -> IO a_aly _ *** Exception: <interactive>:2:1: Found hole ‘_’ with type: IO t0 Where: ‘t0’ is an ambiguous type variable In the first argument of ‘GHC.GHCi.ghciStepIO :: IO a_aly -> IO a_aly’, namely ‘_’ In a stmt of an interactive GHCi command: it <- GHC.GHCi.ghciStepIO :: IO a_aly -> IO a_aly _ (deferred type error) Prelude> }}} It should ideally not expose `ghciStepIO` to the user. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10249#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10249: GHCi leaky abstraction: error message mentions `ghciStepIO` -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: thomie Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Incorrect | Test Case: warning at compile-time | ghci/scripts/T10249 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1528 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * owner: => thomie * testcase: => ghci/scripts/T10249 * differential: => Phab:D1528 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10249#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10249: GHCi leaky abstraction: error message mentions `ghciStepIO` -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: thomie Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Incorrect | Test Case: warning at compile-time | ghci/scripts/T10249 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1527, Wiki Page: | Phab:D1528 -------------------------------------+------------------------------------- Changes (by thomie): * differential: Phab:D1528 => Phab:D1527, Phab:D1528 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10249#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10249: GHCi leaky abstraction: error message mentions `ghciStepIO`
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner: thomie
Type: bug | Status: new
Priority: normal | Milestone: 8.0.1
Component: GHCi | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Incorrect | Test Case:
warning at compile-time | ghci/scripts/T10249
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1527,
Wiki Page: | Phab:D1528
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10249: GHCi leaky abstraction: error message mentions `ghciStepIO` -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: thomie Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: GHCi | Version: 7.10.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Incorrect | Test Case: warning at compile-time | ghci/scripts/T10249 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1527, Wiki Page: | Phab:D1528 -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed Comment: This appears to be fixed however there is no test by the name `T10249` (although `T10248` is quite related). I've gone ahead and added the test. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10249#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10249: GHCi leaky abstraction: error message mentions `ghciStepIO`
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner: thomie
Type: bug | Status: closed
Priority: normal | Milestone: 8.2.1
Component: GHCi | Version: 7.10.1
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Incorrect | Test Case:
warning at compile-time | ghci/scripts/T10249
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1527,
Wiki Page: | Phab:D1528
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10249: GHCi leaky abstraction: error message mentions `ghciStepIO` -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Incorrect | Test Case: warning at compile-time | ghci/scripts/T10249 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1527, Wiki Page: | Phab:D1528 -------------------------------------+------------------------------------- Changes (by thomie): * owner: thomie => (none) * status: closed => new * resolution: fixed => Comment: The example from comment:2 is not fixed yet: {{{ $ ghci GHCi, version 8.4.3: http://www.haskell.org/ghc/ :? for help Prelude> x <- 'a' <interactive>:1:6: error: • Couldn't match expected type ‘IO a0’ with actual type ‘Char’ • In the first argument of ‘GHC.GHCi.ghciStepIO :: forall a. IO a -> IO a’, namely ‘'a'’ In a stmt of an interactive GHCi command: x <- GHC.GHCi.ghciStepIO :: forall a. IO a -> IO a 'a' }}} WIP patch here: https://phabricator.haskell.org/D1528 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10249#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10249: GHCi leaky abstraction: error message mentions `ghciStepIO` -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Incorrect | Test Case: warning at compile-time | ghci/scripts/T10249 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1527, Wiki Page: | Phab:D1528 -------------------------------------+------------------------------------- Comment (by simonpj): Gah. I had a quick look, and it's fiddly. When you write {{{ a <- e }}} at the prompt, we get into `TcRnDriver.tcUserStmt`; in the second equation (i.e. not the `BodyStmt` case). It does this {{{ ; let gi_stmt | (L loc (BindStmt ty pat expr op1 op2)) <- rn_stmt = L loc $ BindStmt ty pat (nlHsApp ghciStep expr) op1 op2 | otherwise = rn_stmt }}} which transforms the Stmt to {{{ a <- (ghciStepIO :: forall a. M a -> IO a) e }}} where `M` is the currently-in-force GHCi monad. Apparently, via `TcRnMonad.getGHCiMonad` and `setGHCiMonad`, it is possible to change the monad in which GHCi bindings are understood, using the library class {{{ module GHC.Ghci where class (Monad m) => GHCiSandboxIO m where ghciStepIO :: m a -> IO a }}} to mediate. I can't see this documented in the user manual, or indeed anywhere else. Sigh. Anyway it's this `ghcStepIO` call that the typechecker is complaining about. I can see various ways to avoid this leakage * Typecheck `e` all by iself, checking that it has type `M <something>`, before attempting to typecheck `a <- ghcStepIO e`. This is a bit similar to what happens in "Plan C" of the `BodyStmt` case of `tcUserStmt` (see `This two-step story is very clunky, alas`). * Some how avoid adding the error contexts in `tcExpr` for generated code. Neither of these seems particularly easy. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10249#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC