🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
elcaro Hrm... Just got bit by the fact that `[R-] (...)` is not the same as `(...).reduce(* R- *)` 04:04
using it in a reduction metaop process the list in reverse. can't seem to find this documented
in fact, documentation on R seems hard to lookup in general. only found docs.raku.org/language/operators#R..._operators 04:05
applies to produce/triangular redunction too... 04:06
m: say ([\R~] <a b c>; <a b c>.produce(* R~ *));
camelia ((c cb cba) (a ba cba))
Nemokosch the part you linked: 09:50
_Any infix operator may be called with its two arguments reversed by prefixing with R. **Associativity of operands is reversed as well.**_
for me, this automatically implies that the `[R-] (...)` behavior was valid 09:51
SmokeMachine patrickb: Please, when possible take a look at github.com/FCO/Red/issues/537 09:54
Nemokosch So yeah, the difference is that R- is right-associative while * R- * is left-associative by default, I guess 10:04
okay, this still doesn't explain: 10:06
mm: dd (1,4,5,10).reduce(&infix:<R->)
m: dd (1,4,5,10).reduce(&infix:<R->)
which is sadly still 8
_If &with is the code object of an operator, its inherent identity value and associativity is respected - in other words, (VAL1, VAL2, VAL3).reduce(&infix:<OP>) is the same as VAL1 OP VAL2 OP VAL3 even for operators which aren't left-associative:_ 10:08
this is not true
```perl
> (1,4,5,10).reduce(&infix:<R->)
8
> 1 R- 4 R- 5 R- 10
0
```
Is this a bug?
elcaro I think the difference boils down to the .reduce or .produce methods process 2 args at a time, regardless of the associativity of the operator. The meta-reduction can consider the op before it processes the list, tho this means it can handle infinite seq's 10:12
elcaro m: say ([\R*] (1 .. Inf)).head(3); 10:12
camelia WARNING: unhandled Failure detected in DESTROY. If you meant to ignore it, you can mark it as handled by calling .Bool, .so, .not, or .defined methods. The Failure was:
Cannot .elems a lazy list onto a List
in block <unit> at <tmp> line 1

T…
Nemokosch I mean, take a look at the quote 10:14
it does suggest that the two "queries" should produce (or reduce, hahaha) the same result
elcaro I don't have time to dig into it now... but I assume this behaivior was chosen purposefully. Maybe it was chosen to mirror Haskell's `foldr` and `foldl` 10:16
Nemokosch _Whether reduce accumulates the elements starting from the left or from the right depends on the operator. In the functional programming world, this operation is generally called a fold. With a right-associative operator it is a right fold, otherwise (and usually) it is a left fold. In Raku, you can specify the associativity of an operator with the is assoc._ 10:17
So yes, I don't know the exact definition either but trust me, this is worth reporting 10:18
The behavior explicitly contradicts the documentation so it's either wrong or the documentation needs extra explanation as to why the current description doesn't apply to this scenario 10:20
elcaro bisectable6: say [R-] 1,3,5,10 10:21
bisectable6 elcaro, Will bisect the whole range automagically because no endpoints were provided, hang tight
elcaro, ¦6c (60 commits): «1␤»
elcaro, Nothing to bisect!
elcaro it's always been that way... so probably just needs doc update 10:22
Nemokosch I mean, [R-] _is right_ 10:29
see "Any infix operator may be called with its two arguments reversed by prefixing with R. Associativity of operands is reversed as well."
(1,3,5,10).reduce(infix:<R->) is wrong 10:30
One could say it's wrong for the sole reason that it isn't the same as [R-] but anyway, that's the one that contradicts the docs 10:31
elcaro The associativy is swapped, which is why the meta-reduction does what it does... but .reduce lazily processes 2 args at a time, so it can't possibly to a right-fold 10:36
`(1,3,5,10).reduce(&infix:<R->)` essentially expands to `(((1 R- 3) R- 5) R- 10)`
Nemokosch Come on, I have quoted the docs several times by now 10:37
it explicitly states that the reduce method does take associativity into account, it expands without "parentheses" and it plays the role of foldl AND foldl, depending on the operator
this is a serious enough contradiction to ".reduce lazily processes 2 args at a time, so it can't possibly to a right-fold" 10:39
and indeed, why should/would List.reduce be lazy?
Supply.reduce okay but List.reduce doesn't have to and it has no particularly good reason to
elcaro yeah, WRT laziness, it's more applicable to .produce 10:42
but yes, I can see the docs, particularly the section you copied starting with _Whether reduce accumulates the elements starting from the left or from_
but it never shows examples of this working with .reduce method, only the meta-reduction 10:43
elcaro bisectable6: say (1,3,5,10).reduce(&infix:<R->) 10:48
bisectable6 elcaro, Will bisect the whole range automagically because no endpoints were provided, hang tight
bisectable6 elcaro, ¦6c (60 commits): «7␤» 10:49
elcaro, Nothing to bisect!
Voldenet Can I somehow call methods on hashes to get its keys? 10:51
m: role X { method ACCEPTS($_) { $_.x ~~ $.x } }; class A is X { has $.x; }; say A.new(:5x) ~~ {:5x} but X 10:52
camelia No such method 'x' for invocant of type 'Hash+{X}'
in method ACCEPTS at <tmp> line 1
in block <unit> at <tmp> line 1
Nemokosch there is the keys method, right?
or what do you mean?
elcaro: anyway, I'd say let's not forget this phenomenon because 1. I can still imagine it's a bug 2. if it's no bug, it would be good to get an explanation and add it to the docs 10:53
Voldenet to somehow do this `({:5x} but Magic).x` 10:54
elcaro I will first see if I can find any artifacts in the IRC logs, as well as any existing issues 10:57
MasterDuke m: role X { method FALLBACK(Hash:D: $key) { self{$key} } }; say ({:5x} but X).x   # Voldenet like this? 11:02
camelia 5
Voldenet Yes, exactly! MasterDuke++ 11:03
Nemokosch what is "but" actually? 11:04
Voldenet operator creating value with mixin
elcaro `but` mixes a role in at runtime (as opposed to `class Foo does Bar` which mixes the `Bar` role in at compiletime) 11:11
leont I'm dd()ing an array, but I'm getting a «Cannot .elems a lazy list onto a Array» error and I don't understand why 11:26
It shouldn't be lazy AFAICT 11:27
elcaro leont: Array's can still house lazy Seq's. What's you're array look like 11:33
m: my @a = (1..Inf); say 'no eagerness here'
camelia no eagerness here
leont I know they can, but I'm surprised this is 11:35
leont It's a Never mind. I accidentally used an X where I meant a Z, and then everything exploded 11:37
lizmat clickbaits rakudoweekly.blog/2022/01/31/2022-05-foo-is-42/ 14:28
Geth doc: b10615679b | (Suman Khanal)++ (committed using GitHub Web editor) | doc/Language/py-nutshell.pod6
Update python to raku

As we know python 2 is no longer maintained www.python.org/doc/sunset-python-2/, its better to reflect examples compatible with python 3 unless we mean python 2 explicitly. This patch makes python examples compatible with python 3.
17:41
linkable6 Link: docs.raku.org/language/py-nutshell
Geth doc/circleci: 06b41720f4 | sumanstats++ | 2 files
Remove .circleci folder

Seems like circleci link is dead. As the github action is good, there's no need to keep circleci. Remove.
19:20
doc/circleci: e7ab97e363 | sumanstats++ | README.md
remove circleci from README
doc/circleci: 949e2f2f0b | sumanstats++ | shippable.yml
Remove shippable yml

Doesn't seem to be of use. Remove
doc: sumanstats++ created pull request #4024:
Remove unnecessary files and links
19:23
Geth doc: 0eadc5a489 | (Daniel Sockwell)++ (committed using GitHub Web editor) | doc/Language/objects.pod6
Document `handles(**)` (#4019)

Explains that you can pass a HyperWhatever to the `handles` method and describes how that's different from passing a Whatever.
19:42
linkable6 Link: docs.raku.org/language/objects
Nemokosch lizmat: do you by any chance know something about the strange behavior of List.reduce with infix:<R-> ? 20:11
that is, not taking right-associativity into account (unlike [R-])
lizmat nope
Nemokosch Perhaps it's issue-worthy then? 20:15
Geth doc/circleci: fd77a5e37c | sumanstats++ | 2 files
Revert "Remove .circleci folder"

This reverts commit 06b41720f41b002f1575b20ced338b3b73fbe1c6. CircleCI builds documentation. So keep it.
20:22
doc/circleci: 51d2f935f8 | sumanstats++ | README.md
Revert "remove circleci from README"

This reverts commit e7ab97e36374c986f4bca913cb666ace9c0ba1de.
lizmat probably :-)
Nemokosch to which repository? 21:28
SqrtNegInf h 22:46
[Coke] i 23:01
MasterDuke j 23:03
japhb I am now hearing www.youtube.com/watch?v=i0r8egBvWRM in my head 23:05
MasterDuke heh, i'd never heard that one before 23:16