http://qs321.pair.com?node_id=726148


in reply to Roles and functional programming

Like others, I'm a little confused by the purpose of your post, but one word of warning that may upset your assertion: Perl 6 roles aren't stateless

From Synopsis 12:

Roles may have attributes:
role Pet { has $.collar = Collar.new(Tag.new); method id () { return $.collar.tag } method lose_collar () { undefine $.collar } }

Of course, whatever state they have becomes a part of the instance into which they are composed (Can roles have Class attributes?), which in a way is a little similar to the way Functors acquire transient access to the values they are applied to, but still that state persists.

Given my previously declared (and sometimes comprehensively proven!) lack of Haskell-fu, I'm loath to draw conclusions, but I think that somewhat queers the pitch as far as comparisons between Functors and Roles are concerned.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.