Skip to content

addAnnotationsForPretty breaks layout #91

@isovector

Description

@isovector

Consider the following, completely synthesized term:

import Language.Haskell.GHC.ExactPrint
import OccName
import HsExpr
import HsPat
import RdrName
import GHC
import BasicTypes


z :: LHsExpr GhcPs
z = noLoc $ HsVar NoExt $ noLoc $ Unqual $ mkVarOcc "hi"

c :: LHsExpr GhcPs
c = noLoc $ HsCase noExt z $ MG noExt (noLoc
  [ noLoc $ Match noExt CaseAlt [noLoc $ WildPat noExt] $ GRHSs noExt [noLoc $ GRHS noExt [] z] $ noLoc $ EmptyLocalBinds noExt
  , noLoc $ Match noExt CaseAlt [noLoc $ WildPat noExt] $ GRHSs noExt [noLoc $ GRHS noExt [] z] $ noLoc $ EmptyLocalBinds noExt
  , noLoc $ Match noExt CaseAlt [noLoc $ WildPat noExt] $ GRHSs noExt [noLoc $ GRHS noExt [] z] $ noLoc $ EmptyLocalBinds noExt
  ]) Generated

blarg :: String
blarg =
  let anns = addAnnotationsForPretty [] c mempty
   in exactPrint c anns

The above prints

 case hi of
   _ -> hi
      _ -> hi
      _ -> hi

which is completely broken for layout. It should instead be:

case hi of
  _ -> hi
  _ -> hi
  _ -> hi

See also: #80

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions