Reformatter for Show

Hello everyone! Haskell have nice automatically derivable Show type class. It's quite useful for debugging with one exception. String representation of even moderately large value is completely unreadable (example below). My question is there any tool for reformatting result of show so it could be read by human beings? Real life example of world salad produced by show
Module (SrcLoc {srcFilename = "rec.hs", srcLine = 1, srcColumn = 1}) (ModuleName "Main") [OptionsPragma (SrcLoc {srcFilename = "rec.hs", srcLine = 1, srcColumn = 1}) (Just GHC) "-F -pgmF ./preprocessor "] Nothing (Just [EVar (UnQual (Ident "main"))]) [] [DataDecl (SrcLoc {srcFilename = "rec.hs", srcLine = 3, srcColumn = 1}) DataType [] (Ident "Foo") [] [QualConDecl (SrcLoc {srcFilename = "rec.hs", srcLine = 3, srcColumn = 12}) [] [] (RecDecl (Ident "Foo") [([Ident "asd"],UnBangedTy (TyCon (UnQual (Ident "Int")))),([Ident "fgh"],UnBangedTy (TyCon (UnQual (Ident "String"))))])] [(UnQual ...

On 2 May 2011 22:01, Alexey Khudyakov
Hello everyone!
Haskell have nice automatically derivable Show type class. It's quite useful for debugging with one exception. String representation of even moderately large value is completely unreadable (example below).
My question is there any tool for reformatting result of show so it could be read by human beings?
I'm working on an inspector for it in Emacs, similar to Firebug/Chrome developer bar expansion of objects. If you use Emacs I can let you know when I've done it.

Hi Alexey,
On 2 May 2011 21:01, Alexey Khudyakov
My question is there any tool for reformatting result of show so it could be read by human beings?
http://hackage.haskell.org/package/pretty-show Just use ppShow, instead of show. Hope this helps, Ozgur

Ozgur Akgun wrote:
Hi Alexey,
On 2 May 2011 21:01, Alexey Khudyakov
wrote: My question is there any tool for reformatting result of show so it could be read by human beings?
http://hackage.haskell.org/package/pretty-show
Just use ppShow, instead of show.
ppShow also has a command line tool called ppsh. I run ppsh in an xterm, paste the Show output into the xterm and then hit Control-d to see the formatted output. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/

On Mon, May 2, 2011 at 3:01 PM, Alexey Khudyakov
Hello everyone!
Haskell have nice automatically derivable Show type class. It's quite useful for debugging with one exception. String representation of even moderately large value is completely unreadable (example below).
My question is there any tool for reformatting result of show so it could be read by human beings?
You could use the 'groom' package on Hackage: http://hackage.haskell.org/package/groom It works best for the derived show instances. Antoine
Real life example of world salad produced by show
Module (SrcLoc {srcFilename = "rec.hs", srcLine = 1, srcColumn = 1}) (ModuleName "Main") [OptionsPragma (SrcLoc {srcFilename = "rec.hs", srcLine = 1, srcColumn = 1}) (Just GHC) "-F -pgmF ./preprocessor "] Nothing (Just [EVar (UnQual (Ident "main"))]) [] [DataDecl (SrcLoc {srcFilename = "rec.hs", srcLine = 3, srcColumn = 1}) DataType [] (Ident "Foo") [] [QualConDecl (SrcLoc {srcFilename = "rec.hs", srcLine = 3, srcColumn = 12}) [] [] (RecDecl (Ident "Foo") [([Ident "asd"],UnBangedTy (TyCon (UnQual (Ident "Int")))),([Ident "fgh"],UnBangedTy (TyCon (UnQual (Ident "String"))))])] [(UnQual ...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 03.05.2011 00:43, Antoine Latter wrote:
On Mon, May 2, 2011 at 3:01 PM, Alexey Khudyakov
wrote: Hello everyone!
Haskell have nice automatically derivable Show type class. It's quite useful for debugging with one exception. String representation of even moderately large value is completely unreadable (example below).
My question is there any tool for reformatting result of show so it could be read by human beings?
You could use the 'groom' package on Hackage:
http://hackage.haskell.org/package/groom
It works best for the derived show instances.
Antoine
http://hackage.haskell.org/package/pretty-show
Just use ppShow, instead of show.
Hope this helps, Ozgur
Thanks a lot. It's exactly what I looked for. Both packages do they jobs
participants (5)
-
Alexey Khudyakov
-
Antoine Latter
-
Christopher Done
-
Erik de Castro Lopo
-
Ozgur Akgun