Re: Generating type specs programmatically

Fred Hebert <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CAFA3VZJXCcDRP4GWXV5k_ABpOKc9hqNBBB_v0g8cOMVBVqmKkA@mail.gmail.com>
You might want to look at Typer, since it's whole purpose is to generate
type specs for code that you can directly put in code.

On Sat, Dec 5, 2020 at 3:25 PM Guilherme Andrade <[email protected]> wrote:

> Hello list,
>
> I've been working on a code-generating tool, leveraging `erl_syntax`[1] to
> build an AST containing arbitrary Erlang functions; I then use `erl_pp`[2]
> to generate the corresponding Erlang code and write the result onto a
> source code file.
>
> 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`.
>
> All of the different attempts I've made end up either crashing within
> `erl_syntax` or `erl_pp`, or at best result in INVALID-FORM literals within
> the generated code.
>
> Would any of you be able to point me in the right direction?
>
> Thanks in advance!
>
> [1]: http://erlang.org/doc/man/erl_syntax.html
> [2]: https://erlang.org/doc/man/erl_pp.html
>
> --
> 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.