How to create types that are not Elixir types

How could I create a new type specifically customised, however it is made up of for example further custom types like

type = ?pattern
pattern = :empty | atom | pattern  '*'

You can do that with typespecs: https://hexdocs.pm/elixir/typespecs.html#content

For example:

@type ok :: :ok
@type error :: {:error, term} | :error
@type result :: ok | error

Page not found error seems to be displayed.

Sorry, I updated the link

Thanks a lot and no problem.

Note that typespecs are only used by Dialyzer/Dialyxir, i.e. static analysis tools. Type information is not used at runtime.

3 Likes

Yep. I somehow assumed that the question was about typespecs.

If you need polymorphism you can use protocols.

Thanks again.