[erlang-questions] prettypr and spec

Ulf Wiger ulf@REDACTED
Wed Sep 26 00:48:36 CEST 2012


Someone really should fix the bugs in erl_prettypr.

BR,
Ulf W

Ulf Wiger, Feuerlabs, Inc.
http://www.feuerlabs.com

25 sep 2012 kl. 22:31 skrev Roberto Ostinelli <roberto@REDACTED>:

> Thank you Ulf,
> 
> I've looked at this and it reads from .beam files. Same problem as before: as specified I need to parse string() code.
> 
> Do I really have to write my own erlang indenter? That really seems weird. Isn't there such a thing like a DSL for indenters?
> 
> 
> 
> On Tue, Sep 25, 2012 at 1:34 AM, Ulf Wiger <ulf@REDACTED> wrote:
>> 
>> Roberto,
>> 
>> It appears as if erl_pp:form/1 does a much better job of formatting specs,
>> but then, of course, you lose the comments.
>> 
>> There is also an issue with typed record fields, which seems to affect 
>> erl_prettypr as well. It simply removes the types from record declarations.
>> 
>> Take a look at parse_trans_pp:beam/1. It makes no effort to preserve comments
>> (naturally, since it doesn't expect to find any), but handles specs and typed 
>> records correctly.
>> 
>> https://github.com/uwiger/parse_trans/blob/master/src/parse_trans_pp.erl#L71
>> 
>> This module, BTW, is also made to be used as an escript, and I have the 
>> following convenient alias:
>> 
>> alias pp='escript /Users/uwiger/git/parse_trans/ebin/parse_trans_pp.beam'
>> 
>> Not that the last point was particularly relevant to your particular problem. :)
>> 
>> BR,
>> Ulf W
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120926/48aac650/attachment.htm>


More information about the erlang-questions mailing list