Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,828
    • Issues 4,828
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 452
    • Merge requests 452
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14078

Closed
Open
Created Aug 02, 2017 by dramforever@dramforever

-ddump-json doesn't work well with GHCi

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.

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}]
Trac metadata
Trac field Value
Version 8.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking