After reading Traits: Composable Units of Behaviour
I have the impression that, due to their statelessness, Traits (and Roles) are very much like Functors in some functional languages (SML).
So like map
and anonymous subs bring some first-order functional programming into Perl, Roles bring higher order functional programming constructs allowing us to refactor the stateless logic into separate, more easily composable units.
Update: Thank you for all the answers! To explain what was the purpose of my post - I had this vague intuition (and since my studies 15 years ago I have not touched SML so it really just a remote glitter through the fog) - and I wanted to check how it matches other people understanding of Traits.