why the parentheses after typenames?

Pascal Brisset pascal.brisset@REDACTED
Sun Feb 27 20:33:31 CET 2005

Matthias Lang writes:
 > something I've wondered a few times. In the documentation, types are
 > often denoted by putting parentheses after names, e.g.

This is consistent with the notation for parametric types, e.g.
  queue:in(T, queue(T)) -> queue(T).
  lists:map(fun(A)->B, list(A)) -> list(B).

"string()" is a named type with no type parameters.
"string" is the type of the atom 'string'.

 > I'm guessing "[ArgAtom]" means "a list of ArgAtom which may be
 > empty".

Yes, [T] is syntactic sugar for list(T).

 > But how do I express the return type consisting of a list with
 > exactly one element?

Very few practical typecheckers can deal with lists of a specific
length.  Keywords : dependent types, coq, cayenne.

-- Pascal

More information about the erlang-questions mailing list