Re: Re-exporting modules that export operators...

2020-08-15 Thread Stuart Hungerford
On Sun, Aug 16, 2020 at 9:03 AM Ralph Mellor wrote: > The SO you quote includes an operator. So that's not the problem. > > The SO is written by jnthn. It doesn't get more authoritative than that. That's good to know, although for me the difference between it working and not working (with that e

Re-exporting modules that export operators...

2020-08-14 Thread Stuart Hungerford
Hi, I'm using the technique described in this thread https://stackoverflow.com/questions/61179586/use-haskell-like-prelude-modules-in-a-module-in-raku to re-export module sub-trees in a project. One of these re-export modules also exports an infix operator. The others only export classes and roles

Place for examples in a Raku module?

2020-08-13 Thread Stuart Hungerford
Hi, I'd like to add some example modules to a Raku module I'm working on. These are not strictly tests, nor stand-alone scripts, but modules of compilable code that show suggested ways to use the roles and classes in the module. They're not strictly needed to make use of the module. I can see I c

Re: Combining multiple "is..." traits into one?

2020-08-11 Thread Stuart Hungerford
On Wed, Aug 12, 2020 at 8:12 AM Tobias Boege wrote: > [...] > > Would a custom version of the trait_mod: routine do the trick? > > Yes: > > multi trait_mod: (Routine $r, :$equivalence!) { > trait_mod:($r, :equiv(&infix:<==>)); > trait_mod:($r, :assoc); > } As a supplementary ques

Re: Combining multiple "is..." traits into one?

2020-08-11 Thread Stuart Hungerford
On Wed, Aug 12, 2020 at 8:12 AM Tobias Boege wrote: > > I'm working with roles where the mixing-in classes and roles need to > > have some mixin-specific notion of equality. So I have an Equality > > role that can also be > > mixed in as needed: > > > > role Equality { > > method equal(Equality

Combining multiple "is..." traits into one?

2020-08-11 Thread Stuart Hungerford
Hi, I'm working with roles where the mixing-in classes and roles need to have some mixin-specific notion of equality. So I have an Equality role that can also be mixed in as needed: role Equality { method equal(Equality:D) of Bool:D {...} } To make using the role easier I've created an infix o

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)) == (self.add(x)

Retrofit built-in types with custom roles?

2019-12-31 Thread Stuart Hungerford
Hi, I'm a complete Raku novice and I'm still at the stage of understanding how the major language features are used idiomatically. As an exercise I'd like to do the equivalent of Haskell's typeclass implementation for the built in numeric types. I understand this may well be a misguided exercise