[erlang-questions] Types and Specs support in erl_syntax or erl_prettypr

Jason Rogers juk80x@REDACTED
Thu Mar 1 15:06:24 CET 2012

I've noticed a lack of support for types and specs in erl_syntax or

If you try:

{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(Beam,[abstract_code]).
io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]).

on a beam file with type or spec declarations, the resulting code will
not compile.

Any idea if official support is forthcoming?

I tried to modify both libraries to provide some minimal support for
my own use, but ran into an issue with typed records. A typed record
shows up in the syntax tree twice: as a un-typed record and as a typed
record. And the typed version, which includes all the information
contained in the un-typed declaration, appears after the un-typed

So if you write code to process the typed version, you will end up
with source code that has both a typed and an un-typed declaration.

Is there anyway to get to a single record declaration?


More information about the erlang-questions mailing list