[Haskell-cafe] Reformatter for Show

Alexey Khudyakov alexey.skladnoy at gmail.com
Mon May 2 22:01:14 CEST 2011


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
 > ...



More information about the Haskell-Cafe mailing list