Re: [Haskell-cafe] How to check if two Haskell files are the same?

2008-09-17 Thread Alfonso Acosta
On Wed, Sep 17, 2008 at 1:03 AM, Brandon S. Allbery KF8NH
[EMAIL PROTECTED] wrote:
 On 2008 Sep 16, at 10:30, Mauricio wrote:

 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?

 Compare .hi files?

You an also compare the resulting object files
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to check if two Haskell files are the same?

2008-09-17 Thread Brandon S. Allbery KF8NH

On 2008 Sep 17, at 14:17, Alfonso Acosta wrote:

On Wed, Sep 17, 2008 at 1:03 AM, Brandon S. Allbery KF8NH
[EMAIL PROTECTED] wrote:

On 2008 Sep 16, at 10:30, Mauricio wrote:


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?


Compare .hi files?


You an also compare the resulting object files



On ELF systems (the majority) you have to watch out for the timestamp  
in the ELF header.  I know there is code in the gcc source that does  
object comparisons to verify that stage3 builds match stage2, omitting  
the header.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to check if two Haskell files are the same?

2008-09-17 Thread Chaddaï Fouché
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


[Haskell-cafe] How to check if two Haskell files are the same?

2008-09-16 Thread Mauricio

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?

Thanks,
Maurício

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to check if two Haskell files are the same?

2008-09-16 Thread Antoine Latter
On Tue, Sep 16, 2008 at 9:30 AM, Mauricio [EMAIL PROTECTED] wrote:
 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?

I don't know the answers to your question, but if you're looking for
inspiration on your project you should check out the following two
packages:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-exts

-Antoine
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to check if two Haskell files are the same?

2008-09-16 Thread Brandon S. Allbery KF8NH

On 2008 Sep 16, at 10:30, Mauricio wrote:

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?


Compare .hi files?

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to check if two Haskell files are the same?

2008-09-16 Thread Philip Weaver
On Tue, Sep 16, 2008 at 7:30 AM, Mauricio [EMAIL PROTECTED] wrote:

 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?


I don't know, but you can parse the resulting concrete syntax and compare
the original abstract syntax to the new abstract syntax.



 Thanks,
 Maurício

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to check if two Haskell files are the same?

2008-09-16 Thread John Van Enk
Before you reinvent the wheel, have you looked at Language.Haskell.Pretty?

http://haskell.org/ghc/docs/latest/html/libraries/haskell-src/Language-Haskell-Pretty.html

On Tue, Sep 16, 2008 at 10:30 AM, Mauricio [EMAIL PROTECTED] wrote:

 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?

 Thanks,
 Maurício

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
/jve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe