JuliaCon 2020 (times are in UTC)

BinaryTraits - traits made easy

BinaryTraits is yet another traits package. Its primary goal of the project is to make traits easy to use. The underlying mechanism is Holy Traits. If you think Holy Traits is the powerful engine, then BinaryTraits gives you automatic transmission. It makes traits a lot more pleasant and fun to use.


While Julia does not have official support for interface/traits, a number of traits packages was developed as proof of concepts (SimpleTraits.jl, Traitor.jl, and more recently Traits.jl). When people don't want to use third-party packages, they resort to Holy Traits - a design pattern that is fairly easy to implement.

BinaryTraits provide several macros that make it easier to work with traits.
- A @trait macro for defining new traits. Traits are binary - a data type either has the trait or don't.
- An @implement macro for specifying interface contracts for data types exhibiting a trait.
- An @assign macro for assigning a data type to a trait.
- A @check macro for verifying that a data type conforms to the interface contract as specified by the trait.
- A @traitfn macro for creating dispatching functions as in Holy Traits pattern

BinaryTraits is expected to be used by framework providers that define formal interfaces. As an example, we could create a RowTable trait and put that in Tables.jl. Then, implementers can assign their data types to RowTable and they can verify correctness of their extension easily.