[Haskell-cafe] Re: How to check if two Haskell files are the same?
Mauricio
briqueabraque at yahoo.com
Wed Sep 17 18:17:19 EDT 2008
Chaddaï Fouché a écrit :
> 2008/9/16 Mauricio <briqueabraque at yahoo.com>:
>> 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 ?
Exactly! And with comments removed, since the last
time I checked Language.Haskell.* used not to preserve
that.
>
> 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.
Good idea. I think that's all that I need. I can write a
hash function that filters and transforms like that.
Thanks,
Maurício
More information about the Haskell-Cafe
mailing list