[GHC] #14078: -ddump-json doesn't work well with GHCi

GHC ghc-devs at haskell.org
Wed Aug 2 16:02:58 UTC 2017


#14078: -ddump-json doesn't work well with GHCi
-------------------------------------+-------------------------------------
           Reporter:  dramforever    |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  GHCi           |           Version:  8.2.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Currently, `:set -ddump-json` in `GHCi` causes all errors to be gathered
 to be written out on exit. `ghci -ddump-json` is even worse, only
 resulting in a `[]` being output on exit.

 However, I believe this completely defeats the purpose of this flag in
 GHCi. I expect `ghci -ddump-json` to work like this: for _each_ evaluation
 typed at the GHCi prompt, one JSON array is output for all messages this
 evaluation caused.

 This proposed behavior is consistent with other flags like `-ddump-simpl`,
 and will allow tooling to interact with GHCi nicely.

 Reporting this as a bug because this looks half-supported rather than
 unsupported, and also because of the different behaviors of `ghci -ddump-
 json` and `:set -ddump-json`. Sorry if it was not warranted.

 == Steps to reproduce

 `cmd>` is the shell prompt.

 {{{#!hs

 cmd> ghc --version
 The Glorious Glasgow Haskell Compilation System, version 8.2.1

 cmd> type tmp.hs
 main = print 2 + 2

 cmd> ghci -ddump-json tmp.hs
 GHCi, version 8.2.1: http://www.haskell.org/ghc/  :? for help
 [1 of 1] Compiling Main             ( tmp.hs, interpreted )

 tmp.hs:1:8: error:
     ? No instance for (Num (IO ())) arising from a use of ‘+’
     ? In the expression: print 2 + 2
       In an equation for ‘main’: main = print 2 + 2
   |
 1 | main = print 2 + 2
   |        ^^^^^^^^^^^
 Failed, 0 modules loaded.
 Prelude> :q
 Leaving GHCi.
 []

 cmd> ghci
 GHCi, version 8.2.1: http://www.haskell.org/ghc/  :? for help
 Prelude> :set -ddump-json
 Prelude> :l tmp.hs
 [1 of 1] Compiling Main             ( tmp.hs, interpreted )

 tmp.hs:1:8: error:
     ? No instance for (Num (IO ())) arising from a use of ‘+’
     ? In the expression: print 2 + 2
       In an equation for ‘main’: main = print 2 + 2
   |
 1 | main = print 2 + 2
   |        ^^^^^^^^^^^
 Failed, 0 modules loaded.
 Prelude> :q
 Leaving GHCi.
 [
  {"span": {"file": "tmp.hs","startLine": 1,"startCol": 8,"endLine":
 1,"endCol": 19},"doc": "\u2022 No instance for (Num (IO ())) arising from
 a use of \u2018+\u2019\n\u2022 In the expression: print 2 + 2\n  In an
 equation for \u2018main\u2019: main = print 2 + 2","severity":
 "SevError","reason": null},

  {"span": null,"doc": "[1 of 1] Compiling Main             ( tmp.hs,
 interpreted )","severity": "SevOutput","reason": null}]
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14078>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list