Protocols
Aug 22, 2023
Table of Contents
Protocols add polymorphic dispatch to Elixir. They are contracts implementable by data types.
The standard protocols are:
| Protocol | Description |
|---|---|
| Collectable | collects data into a data type |
| Enumerable | handles collections in Elixir, as Enum module for eager functions and Stream module for lazy functions |
| Inspect | converts data types into their programming language representation |
| List.Chars | converts data types to their outside world representation as charlists (non-programming based) |
| String.Chars | converts data types to their outside world representation as strings (non-programming based) |