Language.C and non-pretty-printing

Benedikt Huber benedikt.huber at gmail.com
Thu May 5 13:09:28 BST 2011


On 05.05.2011, at 12:20, Alexander Bernauer wrote:

> Hi Benedikt,
>
> thank you for your work. I have a question, though.
>
> The Show instances for the C operators do not return valid Haskell
> syntax. Instead they return the C syntax of those operators. For
> instance:
> [...]
> Instead of the string "<" there should be the string "CLeOp". Is  
> there a
> specific reason for this? Similarily, why isn't the Show instance for
> Ident using regular " quotes?
Hi Alexander,
no, there is no specific reason I know of. Also I agree that, if only  
for
consistency reasons, the Show instances should be standard, and
pretty printing should be done using the Pretty class.
>
> The reason why I would appreciate having valid Haskell syntax is  
> that in
> my daily work with laguage-c it is very helpfull to be able to dump  
> the
> AST of a sample program so that I can figure out the correct match
> patterns.
>
> To this end I am using the Haskell parser module to parse and pretty
> print the AST dump from language-c. For the above example this looks
> like this:
> [...[
> So, would it be possible that
> 1) the Show instance for Ident uses " instead of ' and `?
> 2) the Show instances for the C operators return the name of the
>   respective data constructors?
> 3) the Pretty instances for the C operators don't rely on their Show
>   instances any more but return the correct C syntax string on their  
> own?
> If you say yes, I will go ahead and make a patch for that. I would  
> also
> add my above mentioned pretty printing util.
Yes, sure. I  did not see your offer to create a patch, so I just wrote
one for (2) and (3) [attached]. Could you review it or compare it to
your changes, and add a patch for (1)?

cheers,
benedikt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pretty_ops.dpatch
Type: application/octet-stream
Size: 41890 bytes
Desc: not available
URL: <http://projects.haskell.org/pipermail/language-c/attachments/20110505/44d8a568/attachment-0001.obj>
-------------- next part --------------



>
> regards
>
> Alex
> _______________________________________________
> Language-c mailing list
> Language-c at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/language-c



More information about the Language-c mailing list