Ticket #188 (closed bug report: fixed)

Opened 5 years ago

Last modified 5 years ago

Output of data/newtype puts newlines after the "data" but before the head.

Reported by: solidsnack Owned by: nibro
Priority: major Milestone:
Component: exactprinter Version:
Keywords: Cc:

Description

One ends up with output like:

data











     Maybe t = Just t | Nothing

Change History

follow-up: ↓ 2   Changed 5 years ago by solidsnack

I can not attach files so here you go:

  • .5.1/src/Language/Haskell/Exts/Annotated/ExactPrint.hs

    Wed Dec 30 10:48:26 PST 2009  Jason Dusek <jason.dusek@gmail.com>
      * Clarity/uniformity.
    Wed Dec 30 10:20:25 PST 2009  Jason Dusek <jason.dusek@gmail.com>
      * Would work if we actually parsed a location.
    diff -rN -u old-haskell-src-exts-1.5.1/src/Language/Haskell/Exts/Annotated/ExactPrint.hs new-haskell-src-exts-1.5.1/src/Language/Haskell/Exts/Annotated/ExactPrint.hs
    old new  
    448448    AssocRight l -> printString "infixr" 
    449449 
    450450instance ExactP DataOrNew where 
    451   exactP (DataType l) = printString "data" 
    452   exactP (NewType  l) = printString "newtype" 
     451  exactP dn = 
     452      let a = (srcInfoSpan . ann) dn 
     453          tag = case dn of { DataType _ -> "data" ; NewType _ -> "newtype" } 
     454       in printStringAt (pos a) tag 
    453455 
    454456instance ExactP Decl where 
    455457  exactP decl = case decl of 

in reply to: ↑ 1   Changed 5 years ago by solidsnack

Replying to solidsnack:

I can not attach files so here you go:

Recovering the diff from this Trac markup processor is pretty hard.

Wed Dec 30 10:48:26 PST 2009  Jason Dusek <jason.dusek@gmail.com>
  * Clarity/uniformity.
Wed Dec 30 10:20:25 PST 2009  Jason Dusek <jason.dusek@gmail.com>
  * Would work if we actually parsed a location.
diff -rN -u old-haskell-src-exts-1.5.1/src/Language/Haskell/Exts/Annotated/ExactPrint.hs new-haskell-src-exts-1.5.1/src/Language/Haskell/Exts/Annotated/ExactPrint.hs
--- old-haskell-src-exts-1.5.1/src/Language/Haskell/Exts/Annotated/ExactPrint.hs	2009-12-30 11:16:40.000000000 -0800
+++ new-haskell-src-exts-1.5.1/src/Language/Haskell/Exts/Annotated/ExactPrint.hs	2009-12-30 11:16:40.000000000 -0800
@@ -448,8 +448,10 @@
     AssocRight l -> printString "infixr"
 
 instance ExactP DataOrNew where
-  exactP (DataType l) = printString "data"
-  exactP (NewType  l) = printString "newtype"
+  exactP dn =
+      let a = (srcInfoSpan . ann) dn
+          tag = case dn of { DataType _ -> "data" ; NewType _ -> "newtype" }
+       in printStringAt (pos a) tag
 
 instance ExactP Decl where
   exactP decl = case decl of

  Changed 5 years ago by nibro

  • status changed from new to closed
  • resolution set to fixed

The bug is real but the fix is not. The problem is that exactPrint always prints the first token at (0,0) regardless of where it should really be printed. The fix is that exactPrint should call exactPC, not exactP. Fixed in 1.5.2, case closed.

Note: See TracTickets for help on using tickets.