yav / pretty-show

Tools for working with derived Show instances in Haskell.
MIT License
57 stars 15 forks source link

pretty-show 1.10 fails haskell-src-exts' test suite #45

Open felixonmars opened 4 years ago

felixonmars commented 4 years ago

4 out of the 5 test failures in the recent haskell-src-exts issue https://github.com/haskell-suite/haskell-src-exts/issues/448 seems to be new pretty-show not willing to prettify the result.

One of the examples is:

--- /build/haskell-src-exts/src/haskell-src-exts-1.21.1/tests/examples/Nounpack2.hs.parser.golden        2020-02-22 10:31:04.000000000 +0100
+++ /build/haskell-src-exts/src/haskell-src-exts-1.21.1/tests/examples/Nounpack2.hs.parser.out   2020-02-22 10:34:16.040731529 +0100
@@ -1,96 +1 @@
-ParseOk
-  ( Module
-      SrcSpanInfo
-        { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 1 4 1
-        , srcInfoPoints =
-            [ SrcSpan "tests/examples/Nounpack2.hs" 3 1 3 1
-            , SrcSpan "tests/examples/Nounpack2.hs" 3 1 3 1
-            , SrcSpan "tests/examples/Nounpack2.hs" 3 1 3 1
-            , SrcSpan "tests/examples/Nounpack2.hs" 4 1 4 1
-            , SrcSpan "tests/examples/Nounpack2.hs" 4 1 4 1
-            ]
-        }
-      Nothing
-      []
-      []
-      [ DataDecl
-          SrcSpanInfo
-            { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 1 3 36
-            , srcInfoPoints =
-                [ SrcSpan "tests/examples/Nounpack2.hs" 3 10 3 11 ]
-            }
-          (DataType
-             SrcSpanInfo
-               { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 1 3 5
-               , srcInfoPoints = []
-               })
-          Nothing
-          (DHead
-             SrcSpanInfo
-               { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 6 3 9
-               , srcInfoPoints = []
-               }
-             (Ident
-                SrcSpanInfo
-                  { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 6 3 9
-                  , srcInfoPoints = []
-                  }
-                "Foo"))
-          [ QualConDecl
-              SrcSpanInfo
-                { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 12 3 36
-                , srcInfoPoints = []
-                }
-              Nothing
-              Nothing
-              (ConDecl
-                 SrcSpanInfo
-                   { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 12 3 36
-                   , srcInfoPoints = []
-                   }
-                 (Ident
-                    SrcSpanInfo
-                      { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 12 3 15
-                      , srcInfoPoints = []
-                      }
-                    "Foo")
-                 [ TyBang
-                     SrcSpanInfo
-                       { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 16 3 36
-                       , srcInfoPoints = []
-                       }
-                     (NoStrictAnnot
-                        SrcSpanInfo
-                          { srcInfoSpan = SrcSpan "" (-1) (-1) (-1) (-1)
-                          , srcInfoPoints = []
-                          })
-                     (NoUnpack
-                        SrcSpanInfo
-                          { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 16 3 32
-                          , srcInfoPoints =
-                              [ SrcSpan "tests/examples/Nounpack2.hs" 3 16 3 28
-                              , SrcSpan "tests/examples/Nounpack2.hs" 3 29 3 32
-                              ]
-                          })
-                     (TyCon
-                        SrcSpanInfo
-                          { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 33 3 36
-                          , srcInfoPoints = []
-                          }
-                        (UnQual
-                           SrcSpanInfo
-                             { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 33 3 36
-                             , srcInfoPoints = []
-                             }
-                           (Ident
-                              SrcSpanInfo
-                                { srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 33 3 36
-                                , srcInfoPoints = []
-                                }
-                              "Int")))
-                 ])
-          ]
-          []
-      ]
-  , []
-  )
+ParseOk (Module (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 1 4 1, srcInfoPoints = [SrcSpan "tests/examples/Nounpack2.hs" 3 1 3 1,SrcSpan "tests/examples/Nounpack2.hs" 3 1 3 1,SrcSpan "tests/examples/Nounpack2.hs" 3 1 3 1,SrcSpan "tests/examples/Nounpack2.hs" 4 1 4 1,SrcSpan "tests/examples/Nounpack2.hs" 4 1 4 1]}) Nothing [] [] [DataDecl (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 1 3 36, srcInfoPoints = [SrcSpan "tests/examples/Nounpack2.hs" 3 10 3 11]}) (DataType (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 1 3 5, srcInfoPoints = []})) Nothing (DHead (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 6 3 9, srcInfoPoints = []}) (Ident (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 6 3 9, srcInfoPoints = []}) "Foo")) [QualConDecl (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 12 3 36, srcInfoPoints = []}) Nothing Nothing (ConDecl (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 12 3 36, srcInfoPoints = []}) (Ident (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 12 3 15, srcInfoPoints = []}) "Foo") [TyBang (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 16 3 36, srcInfoPoints = []}) (NoStrictAnnot (SrcSpanInfo {srcInfoSpan = SrcSpan "" -1 -1 -1 -1, srcInfoPoints = []})) (NoUnpack (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 16 3 32, srcInfoPoints = [SrcSpan "tests/examples/Nounpack2.hs" 3 16 3 28,SrcSpan "tests/examples/Nounpack2.hs" 3 29 3 32]})) (TyCon (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 33 3 36, srcInfoPoints = []}) (UnQual (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 33 3 36, srcInfoPoints = []}) (Ident (SrcSpanInfo {srcInfoSpan = SrcSpan "tests/examples/Nounpack2.hs" 3 33 3 36, srcInfoPoints = []}) "Int")))])] []],[])

This used to work fine in pretty-show 1.9.5.

yav commented 4 years ago

Thanks, I see what happened there and I'll fix it soon.

The issue is the handling of negative literals: your Show instance for SrcSpan does not put parens around negative numbers (which means that Read won't work, so you may want to fix this).

pretty-show used to accept these, but I seem to have changed it the last time I tried to add ad-hoc support for dealing with times. I think I should be able to reintroduce it though.