|
NAMElfe_types - LFE Types and Functions SpecificationsTYPESThis is a description of the type syntax.
Apart from the predefined types in the Erlang type system we also have the following predefined types which cannot be redefined: UNION, call, lambda and range. The usage of bitstring, tuple and map have also been extended. The general form of bitstrings is (bitstring m n) which denotes a bitstring which starts with m bits and continues with segments of n bits. (binary) is a short form for a sequence of bytes while (bitstring) is a short form for a sequence of bits. There is currently no short form for an empty binary, (bitstring 0 0) must be used. Type Declarations of User-Defined Types(deftype (type-name) type-def)(defopaque (type-name) type-def) (deftype (type-name par1 par2) type-def) (defopaque (type-name par1 par2) type-def) For unparameterised types the parentheses around the type name are optional. An example:
Type Information in Record Declarations(defrecord rec (field1 default1 type1) (field2 default2) field3)Fields with type annotations MUST give a default value and fields without type annotations get the default type (any). SPECIFICATIONSType specifications of User-Defined Functions(defspec (func-name arity) function-spec ...)where
For multiple types add more function specs. The parentheses around the function name and the arity are optional. For example from the docs:
Or with constraints:
Note that a constraint variable doesn't need to start with an upper-case like an Erlang variable, though in some case it may be easier to read. Note we are using the alternate list form with [ ] instead of parentheses to make it easier to see the function arguments. AUTHORSRobert Virding.
Visit the GSP FreeBSD Man Page Interface. |