[erlang-questions] Type definition

Sean Cribbs seancribbs@REDACTED
Mon Aug 3 22:47:30 CEST 2009


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
>
>




More information about the erlang-questions mailing list