Re: Generating type specs programmatically

Guilherme Andrade <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CAA5f+NWuNEzG7yPL77EUMJ-e6R5aYccU_RUaf7XE8gaDEQ8=Bg@mail.gmail.com>
Hello Viktor,

On Mon, 7 Dec 2020 at 14:25, Viktor Söderqvist <[email protected]>
wrote:

> Hi! Generated examples of all of Erlang's AST is in the generated
> README.md of this repo:
> https://github.com/zuiderkwast/erlang_abstract_format


Thanks! That's a reference document I'll definitely bookmark.


>
>
> Some examples:
>
> -spec my_function() -> ok.
>
> {attribute,54,spec,
>             {{my_function,0},
>              [{type,54,'fun',[{type,54,product,[]},{atom,54,ok}]}]}}
>
> -spec my_function(A :: atom()) -> B when B :: boolean().
>
> {attribute,55,spec,
>      {{my_function,1},
>       [{type,55,bounded_fun,
>            [{type,55,'fun',
>                 [{type,55,product,
>                      [{ann_type,55,[{var,55,'A'},{type,55,atom,[]}]}]},
>                  {var,55,'B'}]},
>             [{type,55,constraint,
>                  [{atom,55,is_subtype},
>                   [{var,55,'B'},{type,55,boolean,[]}]]}]]}]}}
>
> If some syntactic element is missing, please let me know.
>
> BRs,
> Viktor
>
> On 2020-12-05 21:24, Guilherme Andrade wrote:
> > All is well so far, but now I want to generate type specs and function
> > specs with which to annotate the generated code - and I can't for the
> > life of me figure out how to do it within `erl_syntax`.
>


-- 
Guilherme
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.