[erlang-questions] Type definition
Cláudio Amaral
coa@REDACTED
Tue Aug 4 18:11:18 CEST 2009
The objective is not exactly document the code. I am translating erlang
to another language that needs type annotations and I'm using the
parsing libraries in order to have type definitions that I could
manipulate in the abstract tree (and have them in the final program).
Cláudio.
Sean Cribbs escreveu:
> Yes, but that's only for documentation purposes (and for dialyzer,
> IIRC). edoc is the place to start if documentation is your concern:
>
> http://erlang.org/doc/apps/edoc/index.html
>
> Sean
>
> Cláudio Amaral wrote:
>> Yes, but with the "-type" directive we can make definitions in order
>> to document code and stuff. What I want to know is: is it possible to
>> do? If so, how?
>>
>> Sean Cribbs escreveu:
>>> Erlang doesn't have algebraic or polymorphic data types like
>>> Haskell. However, you often compose its simple types to make your
>>> own (a good example from stdlib is the proplist). When dealing with
>>> functions that return different types, you will need to use pattern
>>> matching (possibly with guards) to determine which simple type was
>>> returned.
>>>
>>> Sean
>>>
>>> Cláudio Amaral wrote:
>>>> Can one define polymorphic type definitions?
>>>>
>>>> For example:
>>>>
>>>> poly_tree I::integer B::type
>>>> empty
>>>> | {branch, [B], poly_tree(I,B),poly_tree(I,B)}
>>>>
>>>> where [B] is a list with I elements
>>>>
>>>>
>>>> Regards,
>>>> Cláudio
>>>>
>>>>
>>>> ________________________________________________________________
>>>> erlang-questions mailing list. See http://www.erlang.org/faq.html
>>>> erlang-questions (at) erlang.org
>>>>
>>>>
>>>
>>>
>>>
>>> ________________________________________________________________
>>> erlang-questions mailing list. See http://www.erlang.org/faq.html
>>> erlang-questions (at) erlang.org
>>>
>>
>>
>> ________________________________________________________________
>> erlang-questions mailing list. See http://www.erlang.org/faq.html
>> erlang-questions (at) erlang.org
>>
>>
>
>
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
More information about the erlang-questions
mailing list