Re: Avoiding monkey typing for custom roles on built-in types...

2020-08-09 Thread Ralph Mellor
> Would a better approach be to create custom subtypes of the built-in numeric types that mixin the algebraic roles? It could maybe work out better to mix roles into numeric instances: role G { has Numeric $numeric handles *; has ThreeDObject[:Rotation] $threedobject-rotation handles *;

Re: Avoiding monkey typing for custom roles on built-in types...

2020-08-09 Thread yary
I only superficially read this question–but it does make me think of coercing input types https://docs.raku.org/language/functions.html#Coercion_types https://stackoverflow.com/questions/34874779/what-is-the-point-of-coercions-like-intcool If the methods that do the adding-of-magmas were written

Avoiding monkey typing for custom roles on built-in types...

2020-08-08 Thread Stuart Hungerford
Hi, I'm creating some Raku roles that model algebraic structures: role AddMagma { method add(AddMagma:D, AddMagma:D) of AddMagma:D {...} } role AddSemigroup does AddMagma { multi method add-associativity(AddSemigroup:D \x, AddSemigroup:D \y) of Bool:D { self.add(x.add(y)) ==