<div dir="ltr"><div>This can be done with HaRe, if you use the library version rather than the built-in refactorings. It does not support 7.8.x though, and the 7.10 support is ongoing.<br><br></div>Alan<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 17, 2015 at 6:12 PM, Maurizio Vitale <span dir="ltr"><<a href="mailto:mrz.vtl@gmail.com" target="_blank">mrz.vtl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>G'day!</div><div><br></div>Is there an easy way to extract a single declaration from an Haskell source file and print it with the original formatting?<div><br><div>[I could live with pretty printing, but the default prettyPrint gives me a very strange formatting where something like:</div><div>main = do</div><div> putStrLn "Hello"</div><div>becomes:</div><div>main = do putStrLn "Hello"]</div><div><br></div><div>The closest I've got is to parse the file with comments and then get inside Module ...decls and do printExact with an empty comment list for the decl I'm interested in. This gives me the original formatting and empty lines where comments were that I can then remove.</div><div><br></div><div>But if there was anything already out there that just take a String for the toplevel I'm interested in and convert that only, I'd love to know.</div></div><div><br></div><div>Thanks,</div><div><br></div><div> Maurizio</div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>