Meaning of {...} shorthand in type specifications

The Typespecs reference section in the Elixir docs states the following:

Some shorthands are allowed, such as [...] , <<>> , and {...} .

What type does the {...} shorthand signify? I tried using it in a @spec to find out but I get the following error:

… in typespecs is only allowed inside lists, as in [term(), …], or inside functions, as in (… → term())

I’d expect what they call shorthands in that section refers to [atom] being a shorthand of the parameterized built in type list(atom). Thought that’s curious as built in types are documented as to be defined by type literals (the therefore short forms). {...} is not a valid type as is.

Lists of a singular type, binaries, tuples.

I read {...} as just “a tuple with stuff in it”, ie. they mean you can use things like, {:ok, binary()} instead of tuple(:ok, binary()). But maybe it’s a doc bug, it’s definitely confusing seeing as you can literally have [...]

Thanks for the replies.
@smathy Yes, it’s as you describe. I’ll suggest the docs are updated to clarify this.

1 Like