🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
Nasrudin Matrix is also bridged here :) 00:08
Nasrudin If I have something like class Foo { has &.runme; } 00:24
How could I constrain the assignment of runme to subroutines matching a specific signature?
guifa Nosrudin: how specific? 00:26
Nasrudin Foo.new( runme => -> (Int $a, Str $b) { ... } ) 00:26
So i'd like to do the above
guifa Nasrudin: I would use a subset 00:29
subset Foo of Callable where { … } 00:30
Nasrudin what do I put in the braces? 00:32
guifa Nasrudin: something to specify it. I’m not sure offhand the exact introspection for signatures 00:33
But for example, you can check arity quickly: where { .arity == 2 }
Nasrudin subset Foo of Sub where { .signature.ACCEPTS: \(Int, Str) }; 00:37
Nasrudin That seems to work 00:38
Thanks, that was the missing piece I think :D 00:39
guifa Nice, I actually didn’t even think about using a signature literal
Nasrudin hey I'm too new to Raku ... that was AlexDaniel's suggestion
Nasrudin I just put 2 and 2 together 00:40
Your suggestion has the directness I want ... I actually have a "type" now that I can measure subroutines against
guifa Nasrudin: there are some other options (making a role, for instance), depending on whether you expect adhoc callables or not 01:37
Nasrudin Can you elaborate? 01:38
guifa Nasrudin: subsets have to get checked on asssignment each time. If you made a role with a single ACCEPTS method appropriate signatured, it wouldn’t need to do all those checks. It’s just a case of multiple ways to do similar things 03:19
samebchase- Hi, I'm using the qqx construct to run shell commands. Is there a way in which I can just print/return the generated shell command so that I can inspect the generated output before running it. 05:56
moritz my $command = "$your comand"; say $command; my $result = qqx/$command/; 05:58
samebchase-: ^^
samebchase- wow, thanks moritz! 06:00
AlexDaniel samebchase-: unless you're doing very heavy input validation your qqx code is probably incorrect 09:00
samebchase-: qqx doesn't do anything to prevent shell injection 09:01
lizmat clickbaits rakudoweekly.blog/2020/06/08/2020-...0-rakoons/ 09:09
[ptc] fell into the trap again! 09:10
Geth_ doc: 754e41ea56 | (JJ Merelo)++ | doc/Language/functions.pod6
Add example of referring to operators

Including "generated" ones like XX, mentioned in #2632
09:51
linkable6 Link: docs.raku.org/language/functions
DOC#2632 [open]: github.com/Raku/doc/issues/2632 [Hacktoberfest][RFE][big][docs][good first issue][help wanted][new][⚠ Top Priority ⚠] Checklist for 6.d
finanalyst I'm trying to add a Windows environment to test a module that uses GTK. I haven't used Windows for a while. I have installed apveyor, but I'm not sure the tests have actually run 10:10
Any advice?
JJMerelo finanalyst check out other modules using AppVeyor, like doc 10:13
finanalyst not sure about how the actual windowing thing will work in a containerized environment, though
Geth_ ¦ problem-solving: lizmat assigned to jnthn Issue Managing the Raku project as it is Coming of Age github.com/Raku/problem-solving/issues/203
JJMerelo finanalyst basically you need to download using chocolatey or nuget the needed libraries, and then a rakudo star version compiled for Windows. 10:14
finanalyst JJMerelo: Thanks JJ. I have copied the apveyor test files from GTK::Simple. But the tests have an if statement that avoid contexts without windows 10:15
So the test suite seems to run, but I dont know if they do. 10:16
I'm told my module fails on Windows, so I'm trying to find out why. 10:17
JJMerelo finanalyst ah, OK... I think you can test for different versions using Raku; also for different GTK versions. Try that. Or it might be something that has not been tested... 10:19
finanalyst JJMerelo: Other than GTK and the NativeCall needed to install GTK, the Module (Informative) is simple. I understand that GTK::Simple installs Ok on Windows, but not Informative. 10:20
JJMerelo finanalyst does it install in AppVeyor? So it's a problem with a specific Windows version? 10:21
El_Che hi jj 10:27
lizmat: can you link niner explanation of the 5-3-1 rule (github.com/Raku/problem-solving/is...633507296) in your great post (github.com/Raku/problem-solving/is...635299132) 10:33
it's a little difficult to follow without the link (or better: a very short one sentence explantion what that rule is) 10:34
lizmat El_Che: done
El_Che this could be a summary of it: "when requesting a decision from your manager, describe the problem in 5 sentences, provide 3 solutions and 1 recommendation" 10:36
El_Che back to reading the ticket
finanalyst lizmat: I tried sending you an email on [email@hidden.address] . Hoping to get some help on Perl6-parser 10:37
El_Che githib
I like that
finanalyst shame-faced github 10:38
lizmat finanalyst: hmmm... that should have arrive, whether it'd be githib or github
El_Che githip
finanalyst lizmat: I rechecked. It was addressed to [email@hidden.address] Mistake was here 10:39
lizmat goes through the junk 10:40
finanalyst Oh my!! To be junked on my first email! Like - was it wot I said? :) 10:42
lizmat hehe... I have plenty of mails from yo, just not directly addressed at me :-)
lizmat typically gets 8K - 12K junk mail / month 10:43
and that's the ~20% that actually reaches my mailbox
finanalyst It was only a short message asking if it was a good place to send. Since you are here ... 10:44
lizmat finanalyst: could you try sending it liz at dijkmat.nl ?
finanalyst I'm trying to understand drorr's perl6-parser . But it's not passing a single test. The issue appears to be where you added a commit 10:45
lizmat finanalyst: do you know which commit ?
finanalyst looking
lizmat: commit on Jan 27, 2020. related to changing the name of the compiler. github.com/drforr/perl6-Perl6-Pars...42c40b262f 10:47
lizmat aha... 10:48
finanalyst But I'm not sure that it is your commit that broke the tests. I've not looked at the module before
I want to use pod6 files as a source for html files in a CMS. But invoking the whole raku compiler for each file is slow 10:49
So, I want to find a way to run multiple files through the parser, but instantiate the parser once 10:50
I probably don't need all of perl6-parser 10:51
lizmat hmmm.. simultaneously ?
finanalyst no. iteratively would still be better than reinstantiating for every small pod file 10:52
i think
lizmat hmmm.. all tests pass for me on HEAD 10:53
finanalyst oh!
finanalyst I get: prove -vre 'raku -Ilib' 10:54
./t/00-class-hierarchy.t ......
1..1
Cannot call method 'defined' on a null object
in method parse at /home/richard/development/p6-parser/examples/../lib/Perl6/Parser.pm6 (Perl6::Parser) line 543
in method to-tree at /home/richard/development/p6-parser/examples/../lib/Perl6/Parser.pm6 (Perl6::Parser) line 584
in block <unit> at ./t/00-class-hierarchy.t line 18
This is inside a local copy of the git repo 10:55
lizmat weird, that passes for me 10:59
which version of raku are you on ? 11:00
finanalyst 2019.07.1 built on MoarVM version 2019.07.1
I was wondering if I'm out of date.
is there a way to update from a local terminal? 11:01
eg using zef
I mean update raku
El_Che finanalyst: what os do you run?
finanalyst ubuntu (actually pop!os) 11:02
El_Che I provide repos if you want, and there are also relocable tar.gz if you want a quick install: github.com/rakudo-pkg 11:03
finanalyst El Che: that link has just given me a 404 error 11:04
El_Che github.com/nxadm/rakudo-pkg
sorry
El_Che that one 11:04
finanalyst That's the package I use 11:05
El_Che so why are on an old rakudo? 11:05
finanalyst :) VERY VERY useful. But I haven't updated recent. Shame on me 11:05
El_Che did you pin the package?
ah ok
finanalyst 'pin the package' ??
El_Che you can pin packages on debian/ubuntu so they are not upgraded 11:06
finanalyst i'll check
don't think so
El_Che e.g. if you need a specific version or recent releases have problems: wiki.debian.org/AptConfiguration
package pinning does not happen accidently :)
you probably haven updated in a while :) 11:07
finanalyst oooooh dear. Seems I've missed ALOT of upgrades on lots of things. 11:08
El_Che maybe you updated and the repos are commented out?
finanalyst Not sure. I just ran `apt upgrade` and there are a gazillion upgrades. Not sure why this happened. 11:09
El_Che well if you're running 2019.07.1 there is probably a year of updates missing :) 11:10
finanalyst I know. :( :(
Roamer` BTW... I know I'm a bit paranoid and control-freak-ish sometimes, and I guess it might be too late already, but in such cases I usually do `apt install dpkg apt` first, and then I proceed with the actual upgrade 11:14
El_Che I probably do "apt-get update && apt-get -u dist-upgrade -y && apt-get auto=renove -y" daily on my laptop :) 11:18
Roamer` yeah, "in such cases" meant "other than my daily upgrades" :) 11:20
El_Che :)
finanalyst lizmat: problem found. my whole os distribution was a year out of date. 11:27
lizmat good to hear the source of the issue was found :-) 11:28
finanalyst El Che: Thanks
Roamer`: why update apt first? Are there apt security issues? 11:30
Roamer` finanalyst, nah, but sometimes there are new features, some minor bugfixes, I like to make sure that apt will handle everything correctly during a large upgrade 11:31
as I said, a paranoid control freak :)
finanalyst I understand. 11:32
Roamer` (which doesn't stop me from doing daily upgrades from Debian testing on my laptop, sometimes bringing surprises like today's vlc/smplayer/mesa segfault)
finanalyst My upgrade was seemless today. I have to work out why the daily upgrades stopped. 11:34
El_Che Roamer`: I remember my pre Ubuntu days :) 11:50
grondilu Hi. I want to enumerate the permutations of a list of lists. I've tried something like for (@this, @that, @those).permutations { my (@a, @b, @c) = @$_; } but it doesn't seem to work. What am I missing ? 13:39
jnthn That the @a will slurp up everything (it's a list assignment, not a destructure); true := instead 13:40
grondilu that seems to work, thanks :) 13:41
unrelated : is 'use v6;' still a thing after the renaming ? 13:49
Roamer` grondilu, "use v6" by itself still works, yes, and the more useful forms "use v6.d" or, for the very, very few programs that will break, "use v6.c", will also work and will also cause Perl 5 to break if you run it by mistake 13:58
(at least it's my impression that very few programs written for v6.d will break on v6.c; if I'm wrong, anybody, feel free to correct me)
um, the other way 'round, of course! very few programs written for v6.c will actually break on v6.d 13:59
melezhik I am thinking about writing a series of post on Azure Devops automation using Raku and Sparrow. I wonder if anyone is interested in the topic? 14:29
tellable6 2020-06-06T12:11:21Z #raku-dev <tbrowder> melezhik: good idea for your "spare" time but such testing is not a high need for me.
melezhik .tell tbrowder - I see, NP. 14:34
tellable6 melezhik, I'll pass your message to tbrowder
rbt Is there a standardized deprecation policy for Raku? Timeline between marking the code as deprecated and removing it? 14:42
tbrowder finanalyst: i’ve been very pleased with the rakudo-pkg for debian 14:45
tellable6 tbrowder, I'll pass your message to finanalyst
jnthn rbt: Approximately, something should report itself as deprecated for at least one major language release before being removed. 14:46
ShimmerFairy So long as it's something in core.*/ , it should never need to be removed, unless you wanted to remove support for particular versions of the standard.
rbt It's actually for a module (DBIish). 14:48
rbt It has a bunch of partly functional (and long replaced) code. Would 1 or 2 years be reasonable warning? 14:49
RaycatWhoDat p6: say $_ ~ "ack" for 'J'..'Q' 15:20
camelia Jack
Kack
Lack
Mack
Nack
Oack
Pack
Qack
RaycatWhoDat facepalms
So, in "one-liner mode", this same code throws an error. Why is that? 15:22
It's the "unsupported use of bare say" error. 15:23
ShimmerFairy shell syntax is getting to you, I'm certain
RaycatWhoDat Oh 15:24
You're absolutely right
ShimmerFairy I always use single quotes to surround an argument to -e precisely to avoid the issue :) 15:24
RaycatWhoDat Got it. I will keep that in mind next time. 15:25
Thanks for the help. 15:26
ShimmerFairy np 15:27
[Coke] perl5 question: anyone know what "BBC" is referring to here? github.com/Perl/perl5/issues/17567 is it bbc.co.uk? 15:36
afresh1 I believe it is Blead Breaks CPAN 15:39
Grinnz correct 15:40
some (extremely helpful) users run CPAN smokers using blead, and notify the developers when their changes have started causing failures 15:41
[Coke] very cool 16:08
thanks!
melezhik .tell Grinnz, Blead Breaks CPAN - this what is what done by Blin or RakuDist in Raku 16:42
tellable6 melezhik, I'll pass your message to Grinnz
melezhik at least at somewhat level
softmoth \o 17:11
tellable6 2020-06-09T09:41:01Z #raku-dev <JJMerelo> softmoth not really. I really love what you're doing. There's another fork, which is mine, but it does not go any further than the original.
JJMerelo hi, softmoth. 17:11
Again, thanks and let's go ahead with that
softmoth Hi!
RaycatWhoDat What are the requirements for a method to be called with the invocant first? 17:12
So, if I make a sub like `sub test(Int $input) {!!!}`, what do I need to call it like: `12.test`? 17:13
softmoth JJMerelo, Thanks! I'll move forward on it in softmoth/rakudoc for now. Do you agree w/ moving it to Raku/rakudoc? I'm not in github:Raku org, but I don't mind either submitting PRs or being added, whichever is best for you. Or leaving it on softmoth/rakudoc, too, although I do think it should be under Raku. 17:14
softmoth RaycatWhoDat, you can put it in a class or a role, as `method test(Int $input)` 17:18
RaycatWhoDat Ah, got it. 17:21
[Coke] If you want to modify an existing (core) class, there are a few extra steps.
You can, I think, force a sub to be called "like" a method, but there are extra steps there as well. (trying to find that part of the doc) 17:22
[Coke] m: my $a = "a string"; my method test { return "this is {self}" }; say $a.&test; 17:25
camelia this is a string
[Coke] ^^
I'd file that under tmtowtdi, and put the method in a class, though. :)
JJMerelo softmoth I think it would be a good idea. I could add you either to the team or to the specific repo 17:35
jdv79 [Coke]: enron? really? weren't they in texas or something... 17:44
softmoth JJMerelo, it might make sense to add me to the team; I'm on perl6 but somehow missed the transition 17:52
JJMerelo Let me see if I can do that
softmoth done, you should have received the invitation 17:53
And welcome back
[Coke] jdv79: yes, I lived in Houston for a bit 17:57
softmoth JJMerelo, I got it. Thanks again! 17:59
JJMerelo softmoth++ 18:00
jdv79 [Coke]: ah, cool 18:07
guifa [Coke]: when you call a sub in the method syntax ( my &sub = sub { … }; $foo.&sub ), all that happens is the the invocant is passed as the first argument
guifa so $foo.&sub($bar) is the same as sub($foo, $bar) 18:07
It’s pretty DWIM assuming that — as is normally the case — a sub is written with its first positional argument being the “main” one 18:08
softmoth JJMerelo, It's moved to github.com/Raku/rakudoc ; the only thing missing is it's not showing up (yet?) in travis-ci.org/github/Raku . I don't know if I need to do something more there. 18:32
softmoth It's odd, the travis build badge is green now: api.travis-ci.org/Raku/rakudoc.svg...nch=master But when I go to travis-ci.org/Raku/rakudoc it says they couldn't display the repo. I've logged out & back in to Travis. I have to go now, but will look at it later. 19:21
poohman hello all, 19:24
m: say "test"~~/\U+000C/ 19:25
camelia 5===SORRY!5=== Error while compiling <tmp>
Unrecognized backslash sequence: '\U'
at <tmp>:1
------> 3say "test"~~/\7⏏5U+000C/
expecting any of:
term
poohman In the documentation for regex, it is mentioned that form feed FF is \U+000C
cant I directly use it in a regex? 19:26
jnthn m: say "test"~~/\xC/ 19:28
camelia Nil
jnthn m: say "test"~~/\f/ # but I think this is available too...
camelia Nil
poohman thanks - was just reading a ticket more documentation for this 19:33
oddp .comb allows grouping/chunking of adjacent chars: 19:35
m: "abaabba".comb(/(.) $0*/)
camelia ( no output )
oddp m: say "abaabba".comb(/(.) $0*/) 19:36
camelia (a b aa bb a)
oddp Is there perhaps a more abstract routine in the stdlib that works also for non-string seqs with a custom equality predicate?
categorize, classify and .Bag don't preserve that property:
oddp m: say <a b a a b b a>.categorize({$_}) 19:36
camelia {a => [a a a a], b => [b b b]}
jnthn oddp: Maybe .repeated 19:37
jnthn Though I don't think that's quite what you want 19:38
oddp Nope. 19:38
Looking for the equivalent of this ruby snippet: 19:39
%w(a b a a b b a).chunk(&:itself).to_a
=> [["a", ["a"]], ["b", ["b"]], ["a", ["a", "a"]], ["b", ["b", "b"]], ["a", ["a"]]]
If it's not in the stdlib then that's fine, just wanted to make sure I'm not overlooking something since each and every lang calls these routines differently. :) 19:41
[Coke] m: "abaabba".comb(/(.) $0*/).map({.substr(0,1), $_}) 19:41
camelia ( no output )
[Coke] m: dd "abaabba".comb(/(.) $0*/).map({.substr(0,1), $_}) 19:42
camelia (("a", "a"), ("b", "b"), ("a", "aa"), ("b", "bb"), ("a", "a")).Seq
[Coke] I haven't seen behavior like that before.
easy enough to throw that in a routine, though. 19:44
oddp Yeah, that works for chars and the like, but not for various objects with arbitrary eqv checks.
jnthn oddp: Yeah, I think can't think of a built-in that does exactly that
squish has the information in its hands but throws it away 19:45
[Coke] yah, the comb assumes a string: one sec.
jnthn Well, that's not quite true, it doesn't actually have to keep count of how many things it discarded
oddp "I haven't seen behavior like that before." - It's called group_by/group some other langs (e.g. rust, d, haskell). 19:50
Ruby is the outlier here when it comes to naming these things.
[Coke] does the result need to be an array? Most of things like classify/categorize are hash-generating. 19:51
also, I assume that if it should generalize to more than 2 in a row? 19:52
[Coke] this seems like it would require a multiline sub. Hopefully someone can suggest a shorter way. :) 20:10
oddp Sorry for the delay. 20:17
In this very case I'm only interested in the number of adjacent elements that match a certain predicate. Each language seems to represent the result in a slightly different manner.
haskell, for example, as a lazily accumulated list:
>>> groupBy (<=) [1,2,2,3,1,2,0,4,5,2]
en.wikipedia.org/wiki/Special:Searc...[0,4,5],[2
oops.
=> [ [1,2,2,3],[1,2],[0,4,5],[2] ]
dlang, on the other hand, as an value => count pair iterator. 20:18
[Coke] If you didn't care about repeated items, you could use one of the builtins. (that is, your sample could have two separate runs of as that need to be reported differently) 20:20
MasterDuke could you do something with reduce?
oddp I went with plain old while loop and an accm array. :) 20:21
[Coke] oddp++
wamba m: multi reducer ( @a,$i where * eqv @a.tail.key ) { |@a.head(*-1), @a.tail.key => [|@a.tail.value,$i] }; multi reducer (@a, $i) { |@a,$i=>$i }; say <a b a a b b a>; dd reduce &reducer, [],|<a b a a b b a> 20:24
camelia (a b a a b b a)
(:a("a"), :b("b"), :a(["a", "a"]), :b(["b", "b"]), :a("a"))
oddp .tell wamba, Thanks, appreciated, will see whether I can mold this a bit and add it to a small utils lib. 20:42
tellable6 oddp, I'll pass your message to wamba
oddp A quick question about this statement here: |@a, $i => $i. Will this iterate through the whole array before appending an element?
Or is the the slip essentially optimized away? 20:43
Nasrudin So consider this class: class MyCmd { has Sub &.runme; }; 20:56
If I try this: my $x = MyCmd.new( runme => sub ($a,$b) { say "Hi" } );
it fails with Type check failed in assignment to &!runme; expected Callable[Sub] but got Sub
Can anyone explain this behavior? I'm very new to Raku so bear with me please. :D 20:57
jnthn The sigils other than $ already imply a type, so the & already implies something Callable 20:59
In general, the type is "what do I get out of this", and you get something out of a callable by calling it. So `has &.runme` is enough to express "something I can call" 21:00
`has Sub &.runme` means it has to be something that has a declared return type of Sub 21:01
Nasrudin Ah! That's clear, thank you. :) 21:04
What if I want to specify a signature that the assigned "code reference" (honestly don't know what else to call it) must have? 21:05
I can't use '&' right?
I have to make my own type
and use '$'