[erlang-questions] Type definition

Sean Cribbs seancribbs@REDACTED
Mon Aug 3 21:12:49 CEST 2009


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




More information about the erlang-questions mailing list