Skip to content
GitLab
Projects Groups Snippets
  • /
  • 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 5,348
    • Issues 5,348
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 571
    • Merge requests 571
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #1966
Closed
Open
Issue created Dec 09, 2007 by guest@trac-guest

Incorrect Outputable instance for InstDecl

The pretty-printer produces trash output for instance declarations. This is how the Outputable instance is defined in compiler/hsSyn/HsDecls.lhs:

instance (OutputableBndr name) => Outputable (InstDecl name) where

    ppr (InstDecl inst_ty binds uprags ats)
      = vcat [hsep [ptext SLIT("instance"), ppr inst_ty, ptext SLIT("where")],
              nest 4 (ppr ats),
              nest 4 (ppr uprags),
              nest 4 (pprLHsBinds binds) ]

Notice that 'ats' and 'uprags' are lists, so they are being printed as such, i.e., with braces and commas. This produces output that looks like this:

instance Monad Maybe where
    []
    []
    return = Just
    fail _ = Nothing
    ...

The correct (I think) definition is this:

instance (OutputableBndr name) => Outputable (InstDecl name) where
    ppr (InstDecl inst_ty binds uprags ats)
      = vcat ([hsep [ptext SLIT("instance"), ppr inst_ty, ptext SLIT("where")]] ++
	      [ nest 4 (ppr at) | at <- ats ] ++ 
	      [ nest 4 (ppr uprag) | uprag <- uprags ] ++ 
	      [ nest 4 (pprLHsBinds binds) ])
Trac metadata
Trac field Value
Version 6.9
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC df@dfranke.us
Operating system Multiple
Architecture Multiple
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking