Given that the signature is going to be more complex, it would be
helpful if I do not need to repeat it for every member of the Walkable
class. I tried using a constant to represent the signature so that I can
create new Walkables without having to spell it out. Here is my code
attempt (not wor
On Mon, 20 Jul 2020, Gianni Ceccarelli wrote:
> Aside:
>
> ``(sub (Int $ --> Int) {}) ~~ Walkable`` is false, because
> ``:(Int $ --> Int) ~~ :(Numeric $ --> Numeric)`` is false, which is
> correct because function subtypes should be contravariant in the parameter
> types and covariant in the retu
On Mon, 20 Jul 2020 14:00:33 +0200
Tobias Boege wrote:
> You cannot write `Walkable &w` in the signature of &walker because the
> combination of a type and the &-sigil apparently means that `&w`
> should be Callable and return a Walkable. That's why I use the
> $-sigil.
Aha! That's the bit I got
Thanks Gianni and Tobias,
This is very helpful.
One minor follow-up. If I define by signature like this:
my $sgn-walkable = :(Numeric $n --> Numeric);
I could not define Walkable subs like this, could I?
my Walkable $crawlback = ...
Thanks,
Theo
Tobias Boege schreef op 2020-07-20 14:00:
On
On Mon, 20 Jul 2020, Theo van den Heuvel wrote:
> Hi gurus,
>
> after looking at the documentation on Sub, Signature and the raku type
> system I find myself unable to constrain the types of functions in the way I
> think I need.
>
> The situation: I have a function, let's call in 'walker', whose
On Mon, 20 Jul 2020 12:37:33 +0200
Theo van den Heuvel wrote:
> The situation: I have a function, let's call in 'walker', whose first
> parameter is a callback.
> I wish to express that only callbacks with a certain Signature and
> return type are acceptable.
> Let's say the callback should foll
Hi gurus,
after looking at the documentation on Sub, Signature and the raku type
system I find myself unable to constrain the types of functions in the
way I think I need.
The situation: I have a function, let's call in 'walker', whose first
parameter is a callback.
I wish to express that on