2008/9/16 Mauricio <[EMAIL PROTECTED]>: > Hi, > > I would like to write a Haskell pretty-printer, > using standard libraries for that. How can I > check if the original and the pretty-printed > versions are the same? For instance, is there > a file generated by GHC at the compilation > pipe that is always guaranteed to have the > same MD5 hash when it comes from equivalent > source?
There is not, though I have a suggestion : Am I correct in assuming that you mean "equivalent source" in the sense that only the formatting (and eventually {;} as a layout format consequence) differs ? Then the sequence of tokens from the source ought to do the trick as long as you delete location information (map unLoc) and transform ITvocurly ("virtual" braces for layout induced blocks) into ITocurly (real braces for no-layout blocks) (and same for ITvccurly) (it's just another map). If only the formatting differs, those two should be identical. Now the current GHC don't give you direct access to the Token stream but the next release should contain the functions I wrote to support this (for HaRe). In fact you could do this with the AST but it would be more complicated to do the necessary extractions and comparisons... -- Jedaï _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe