[erlang-questions] Type definition

Cláudio Amaral coa@REDACTED
Mon Aug 3 22:32:47 CEST 2009


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
>



More information about the erlang-questions mailing list