[erlang-questions] Type definition

Kostis Sagonas kostis@REDACTED
Mon Aug 10 10:45:12 CEST 2009


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

Writing polymorphic type definitions is possible in the current Erlang 
version.  For example, you can write the following:

   -type pol_t(I, B) :: 'empty' | {'not_empty', I, [B]}.

What is currently not possible is to write _recursive_ type definitions. 
So it is currently not possible to have a type declaration like the one 
you need for what you want to do.

Kostis


More information about the erlang-questions mailing list