elixir-style-guide icon indicating copy to clipboard operation
elixir-style-guide copied to clipboard

Document the correct parens usage with non zero-arity types

Open lucazulian opened this issue 2 years ago • 0 comments

From this section, we know that with zero-arity types, we must use parens. This is the case for the following examples:

type ::
      any()                     # the top type, the set of all terms
      | none()                  # the bottom type, contains no terms
      | atom()
      | map()                   # any map
      | pid()                   # process identifier
      | port()                  # port identifier
      | reference()
      | tuple()                 # tuple of any size
      | float()
      | integer()
      | neg_integer()           # ..., -3, -2, -1
      | non_neg_integer()       # 0, 1, 2, 3, ...
      | pos_integer()           # 1, 2, 3, ...

but what about optional types in the following cases?

type ::
      | list(type)                                                    # proper list ([]-terminated)
      | nonempty_list(type)                                           # non-empty proper list

or custom types exposing the same behaviour? Should we use parens or not?

lucazulian avatar May 22 '23 07:05 lucazulian